open.mp forum
[Pawn] Compilation error - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Compilation error (/showthread.php?tid=3481)



Compilation error - primat - 2025-09-05

I recieve this error message 
Quote:C:\Users\unity\Documents\Server\qawno\include\sscanf2.inc(33) : user error: Please include <a_npc> or <a_samp> first.

Compilation aborted.

Pawn compiler 3.10.11 Copyright © 1997-2006, ITB CompuPhase


but in my gamemode file it is already included 

Image

Please help me someone


RE: Compilation error - primat - 2025-09-05

Update! Ive fixed it ! But now i have some another issues and i need help to fix it!

There is a list of errors


RE: Compilation error - MrKacu13 - 2025-09-06

Oh, you added open.mp include so you have a two solutions:

1. Add #define SAMP_COMPAT before your includes.
2. Find actual callbacks syntax (it's different) on open.mp wiki and just replace it + for weapons id you should use macro definitions (not ID's). Probably textdraws need it too.

First solution is's definitly a good option for you, beacause you don't need change anything in your code. Just add this define SAMP_COMPAT and gamemode should be build succesful.

In line 51910 you have a redefinition of GetWeaponSlot function. It's arleady defined by default.


RE: Compilation error - primat - 2025-09-07

(2025-09-06, 04:58 PM)MrKacu13 Wrote: Oh, you added open.mp include so you have a two solutions:

1. Add #define SAMP_COMPAT before your includes.
2. Find actual callbacks syntax (it's different) on open.mp wiki and just replace it + for weapons id you should use macro definitions (not ID's). Probably textdraws need it too.

First solution is's definitly a good option for you, beacause you don't need change anything in your code. Just add this define SAMP_COMPAT and gamemode should be build succesful.

In line 51910 you have a redefinition of GetWeaponSlot function. It's arleady defined by default.

There is one more error :

Error and code


RE: Compilation error - primat - 2025-09-07

This is a stock :

Code:
stock Convert(seconds, stringTos[], size = sizeof(stringTos))
{
    stringTos[0] = 0x0;
    new result[4];
    result[0] = floatround(seconds / (3600 * 24));
    result[1] = floatround(seconds / 3600);
    result[2] = floatround((seconds / 60) - (result[1] * 60));
    result[3] = floatround(seconds - ((result[1] * 3600) + (result[2] * 60)));
    switch(result[0])
    {
case 0:
{
switch(result[1])
{
case 0: format(stringTos,size,"%d:%02d",result[2],result[3]);
default: format(stringTos,size,"%d:%d:%02d",result[1],result[2],result[3]);
}
}
    }
    return stringTos;// Convert(time[0]/1000, timew[0]);//51
}



RE: Compilation error - primat - 2025-09-07

I've already found an issue (chatGPT helped me) :)

This happened because my
Code:
Convert
 function was trying to
Code:
return stringTos;
, but in Pawn you cannot return arrays of unknown size.

The solution was to remove the
Code:
return
statement and simply let the function fill the string that is passed by reference. The function call stays the same:

Code:
new time[32];

Convert(GetPVarInt(playerid, "schet_time_to_finish"), time);

Thanks to ChatGPT for helping me figure this out!


RE: Compilation error - MrKacu13 - 2025-09-07

Okay, you have this error, because you can't return array in Pawn stock function.
I made some changes and it works fine. Here's code:
Code:
stock Convert(seconds, stringTos[], size = sizeof(stringTos))
{
    stringTos[0] = 0x0;
    new result[4];
    result[0] = floatround(seconds / (3600 * 24));
    result[1] = floatround(seconds / 3600);
    result[2] = floatround((seconds / 60) - (result[1] * 60));
    result[3] = floatround(seconds - ((result[1] * 3600) + (result[2] * 60)));
    switch(result[0])
    {
        case 0:
        {
            switch(result[1])
            {
                case 0: format(stringTos, size, "%d:%02d", result[2], result[3]);
                default: format(stringTos, size, "%d:%d:%02d", result[1], result[2], result[3]);
            }
        }
    }
    return 1;// Convert(time[0]/1000, timew[0]);//51
}

And this is example:
Code:
new buffer[128];
Convert(6000, buffer);
SendClientMessage(playerid, -1, "%s", buffer); //it returns string: 1:40:00