SA-MP Forums Archive
Function error - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Function error (/showthread.php?tid=665021)



Function error - SymonClash - 19.03.2019

pawn Код:
stock SetAdminDuty(playerid, state)
{
    switch(state)
    {
        case 1:
        {
            OnDuty[playerid] = 1;
           
            SetPlayerHealth(playerid, FLOAT_INFINITY);
           
            SCMTAEX(COLOR_YELLOW, "» %s (%d) is now on duty.", ReturnPlayerName(playerid), playerid);

            SetPlayerColor(playerid, COLOR_YELLOW);
        }
       
        case 0:
        {
            OnDuty[playerid] = 0;
           
            SetPlayerHealth(playerid, MAX_HEALTH);
           
            SCMTAEX(COLOR_YELLOW, "» %s (%d) is now off duty.", ReturnPlayerName(playerid), playerid);
           
            new col = random(sizeof (PlayerColors));
            SetPlayerColor(playerid, PlayerColors[col]);
        }
    }
}
In the /duty cmd:

pawn Код:
switch(OnDuty[playerid])
    {
        case 0: SetAdminDuty(playerid, 1); //Admin duty is off, enable it...
        case 1: SetAdminDuty(playerid, 0); //Admin duty is on, disable it...
    }
Getting this errors:

Quote:

error 010: invalid function or declaration
error 001: expected token: "-identifier-", but found ")"
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition




Re: Function error - SymonClash - 19.03.2019

So what i have to do?


Re: Function error - SymonClash - 19.03.2019

Quote:
Originally Posted by ******
Посмотреть сообщение
Name it something else, like `isOn`. Also, why are you using `switch` for true/false, and not using `bool:`? And `SCMTAEX` is the worst function name I've ever seen. Most functions should include at least a verb and a noun to tell you what they're operating on and what they're doing with it. That tells you nothing.
Ok i'll nominate them.

About SCMATEX means SendClientMessageEx, it's just a macro to abbreviate it. And i know what they're operating and what they do, no problem.


Re: Function error - SymonClash - 19.03.2019

Ah ok you're right then, next time i'll explain. But i think seems clear what SCMTAEX does. (Sends a formatted message).

However i fixed, you can close this topic.