Small zcmd problem
#1

On top
pawn Код:
#include <zcmd>
Under public OnPlayerCommandText(playerid, cmdtext[])

pawn Код:
COMMAND:zcmdtest(playerid, params[])
{
      SendClientMessage(playerid,culoare,"This is an test cmd");
      return 1;
}
The errors :
Код:
 error 029: invalid expression, assumed zero
 error 017: undefined symbol "cmd_zcmdtest"
 error 029: invalid expression, assumed zero
Reply
#2

It should NOT be placed under OnPlayerCommandText!

Read the how-to in the ZCMD topic before trying to use it.
Reply
#3

So where should it be placed ? coz under onplayertext it does the same thing .
Reply
#4

It should be placed lnywhere in your script just not under any callback.
Reply
#5

Ok , thanx 4 the info .

LE : So variabiles like
Код:
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
I have to place them under all cmd's that use them ?
Reply
#6

Well either that, or you could place them at the begining of your script.

I use PlayerName[playerid] so i don't need to use GetPlayerName and don't need those variables.

pawn Код:
new PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME]; // At top of script.

GetPlayerName(playerid, PlayerName[playerid], MAX_PLAYER_NAME); // Under OnPlayerConnect.
Example:

pawn Код:
cmd(sethp, playerid, params[])
{
    new string[128];
    if(IsPlayerConnectedAndLoggedIn(playerid))
    {
        if(PlayerInfo[playerid][pAdmin] > 0)
        {
            new player; new health;
            if(sscanf(params, "ud",player,health))
            {
                SendClientMessage(playerid, COLOR_HELP, "USAGE: /sethp [ID/DioImena] [0-100]");
                return 1;
            }
            if(health < 0 || health > 100)
            {
                SendClientMessage(player,COLOR_INFO,"ERROR: You can't set health below 0 or above 100.");
                PlayerPlaySound(player, 1055, 0.0, 0.0, 0.0);
                return 1;
            }
            if(IsPlayerConnectedAndLoggedIn(player))
            {
                if(player != INVALID_PLAYER_ID)
                {
                    SetPlayerHealth(player,health);
                    format(string, sizeof(string), "AdmWarn: Administrator %s set health of %s to %d.",PlayerName[playerid],PlayerName[player],health);
                    SendAdminMessage(COLOR_RED,string);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_ERROR, "ERROR: Choosed player isn't curently online or logged in.");
                PlayerPlaySound(playerid,1055,0.0,0.0,0.0);
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are not authorized to use this command.");
            PlayerPlaySound(playerid, 1055, 0.0, 0.0, 0.0);
        }
    }
    return 1;
}
Look at the AdmWarn part, there's the usage.

Hope it helps.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)