Params 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)
+--- Thread: Params problem (
/showthread.php?tid=436415)
Params problem -
yaron0600 - 11.05.2013
Hey this is my command I've transferd to the script with no zcmd , And the only one errors iis that :
Код:
Undefinde symbol Params...
Код:
if(strcmp(cmd, "/revive", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
new string[128], giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /revive [playerid]");
if(IsPlayerConnected(giveplayerid))
{
if(GetPVarInt(giveplayerid, "Injured") == 1)
{
format(string, sizeof(string), " You have revived %s.", GetPlayerName(giveplayerid));
SendClientMessage(playerid, COLOR_WHITE, string);
SendClientMessage(giveplayerid, COLOR_WHITE, "You have been revived by an Admin.");
ClearAnimations(giveplayerid);
SetPlayerHealth(giveplayerid, 100);
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "That player is not injured!");
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
}
return 1;
}
Re: Params problem -
Kwarde - 11.05.2013
For 'params', you must use (for example) ZCMD and not the old, slow strcmp&OnPlayerCommandText!
Re: Params problem -
yaron0600 - 11.05.2013
What should I do for enter that command ?!
Re : Params problem -
Rayan_black - 11.05.2013
Well, convert it to ZCMD.
pawn Код:
CMD:revive(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
new string[128], giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /revive [playerid]");
if(IsPlayerConnected(giveplayerid))
{
if(GetPVarInt(giveplayerid, "Injured") == 1)
{
format(string, sizeof(string), " You have revived %s.", GetPlayerName(giveplayerid));
SendClientMessage(playerid, COLOR_WHITE, string);
SendClientMessage(giveplayerid, COLOR_WHITE, "You have been revived by an Admin.");
ClearAnimations(giveplayerid);
SetPlayerHealth(giveplayerid, 100);
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "That player is not injured!");
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
}
return 1;
}
this should od the job.
Re: Params problem -
Rillo - 11.05.2013
Quote:
Originally Posted by yaron0600
What should I do for enter that command ?!
|
Use ZCMD
Then
Код:
if(strcmp(cmd, "/revive", true) == 0)
Will become
Код:
CMD:revive(playerid, params[])
Re: Params problem -
yaron0600 - 11.05.2013
LOL , YOu think I cant do that ?! ALL MY SCRIPT IS if(strcmp(cmd, "/cmd", true) == 0)
Re: Params problem -
Kwarde - 11.05.2013
Then don't do it and find a nother way to check those parameters.. strtok, for example. If you use this slow strcmp, why not use slow strtok too?