Problem with command
#1

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
Reply
#2

which line is 73167?
Reply
#3

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.
Reply
#4

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

I included ZCMD, and same errors.
Reply
#6

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.
Reply
#7

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;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)