Small zcmd problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Small zcmd problem (
/showthread.php?tid=185317)
Small zcmd problem -
Dj_maryo1993 - 24.10.2010
On top
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
Re: Small zcmd problem -
LarzI - 24.10.2010
It should
NOT be placed under OnPlayerCommandText!
Read the how-to in the ZCMD topic before trying to use it.
Re: Small zcmd problem -
Dj_maryo1993 - 24.10.2010
So where should it be placed ? coz under onplayertext it does the same thing .
Re: Small zcmd problem -
Whizion - 24.10.2010
It should be placed lnywhere in your script just not under any callback.
Re: Small zcmd problem -
Dj_maryo1993 - 24.10.2010
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 ?
Re: Small zcmd problem -
Whizion - 24.10.2010
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.