SA-MP Forums Archive
Problem with command - 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: Problem with command (/showthread.php?tid=378502)



Problem with command - UnknownGamer - 17.09.2012

Hi people,

How would I fix this

pawn Код:
CMD:quitjob(playerid,params[])
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pJob] > 0)
            {
                if(PlayerInfo[playerid][pRegularRank] > 0)
                {
                        SendClientMessage(playerid, COLOR_WHITE, "You have quit a job!");
                        PlayerInfo[playerid][pJob] = 0;
                        PlayerInfo[playerid][pChar] = 0;
                        PlayerInfo[playerid][pContractTime] = 0;
                        SetPlayerToTeamColor(playerid);
                    }
                    else
                    {
                    SendClientMessage(playerid, COLOR_GREY, "You do not have a job!");
                    }
                return 1;
                }
            }
        }
errors:

C:\Users\matthew\Desktop\V2 NG LS;RP\gamemodes\larp.pwn(73167) : error 029: invalid expression, assumed zero
C:\Users\matthew\Desktop\V2 NG LS;RP\gamemodes\larp.pwn(73167) : error 017: undefined symbol "cmd_quitjob"
C:\Users\matthew\Desktop\V2 NG LS;RP\gamemodes\larp.pwn(73167) : error 029: invalid expression, assumed zero
C:\Users\matthew\Desktop\V2 NG LS;RP\gamemodes\larp.pwn(73167) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664


AW: Problem with command - arvifilter - 18.09.2012

which line is 73167?


Re: Problem with command - antonio112 - 18.09.2012

Try it this way:
pawn Код:
CMD:quitjob(playerid,params[])
{
    if(PlayerInfo[playerid][pJob] == 0)
        return SendClientMessage(playerid, COLOR_GREY, "You do not have a job!");

    SendClientMessage(playerid, COLOR_WHITE, "You have quit a job!");
    PlayerInfo[playerid][pJob] = 0;
    PlayerInfo[playerid][pChar] = 0;
    PlayerInfo[playerid][pContractTime] = 0;
    SetPlayerToTeamColor(playerid);
    return 1;
}
You don't have to check if the player who types the command is connected. It makes no sense at all.


Re: Problem with command - trapstar2020 - 18.09.2012

did u include zcmd
Код:
#include <zcmd>
REP ++ IF ive help u


Re: Problem with command - UnknownGamer - 18.09.2012

I included ZCMD, and same errors.


Re: Problem with command - clarencecuzz - 18.09.2012

Did you put this code under any public functions??
NOTE: Commands when using ZCMD shouldn't be placed under any public functions, but in their own external space.
Example of a WRONG COMMAND PLACEMENT
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    CMD:quitjob(playerid, params[])
    {
        return 1;
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}
Example of a CORRECT COMMAND PLACEMENT:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    return 1;
}

CMD:quitjob(playerid, params[])
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}
Look at how the Command is not actually residing inside any public function. It does not have to be between them, it can be placed anywhere as long as all definitions and includes have been defined before its use.


Re: Problem with command - Devilxz97 - 18.09.2012

place the ZCMD commands Outside a Callbacks.
or it will not works

Edit: try this.

pawn Код:
CMD:quitjob(playerid,params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pJob] >= 0)
        {
            if(PlayerInfo[playerid][pRegularRank] >= 0)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You have quit a job!");
                PlayerInfo[playerid][pJob] = 0;
                PlayerInfo[playerid][pChar] = 0;
                PlayerInfo[playerid][pContractTime] = 0;
                SetPlayerToTeamColor(playerid);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You do not have a job!");
            }
        }
    }
    return 1;
}