My cmd doesn't work? - 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: My cmd doesn't work? (
/showthread.php?tid=409449)
My cmd doesn't work? -
Oscii - 21.01.2013
Hello,i'm having a problem with my /sethuman command on my script, it doesn't seem to actually set the playerid i'm trying to make it! anyone know how to fix this?
pawn Код:
if (strcmp("/sethuman", cmdtext, true) == 0)
{
if(PlayerInfo[playerid][jAdmin] < 3) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");//Checking if the player has admin level 3, if not it sends him a message.
new targetid;
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player not connected!");
else
{
format(string, sizeof(string), "%s has set you to human.", PlayerName(playerid));
SendClientMessage(targetid, BLANCO, string);
gTeam[targetid] = EHUMAN;
HumanTeamCambia(targetid);
PlayerInfo[targetid][jZombie] = 0;
PlayerInfo[targetid][jInfected] = 0;
}
return 1;
}
Regards
Oscii
Re: My cmd doesn't work? -
[XST]O_x - 21.01.2013
Of course it won't.
You defined targetid, but didn't give it any value. So targetid contains junk, and when you perform the command on it nothing happens because it's not a valid player ID.
Use sscanf for commands with parameters.
Re: My cmd doesn't work? -
Oscii - 21.01.2013
I don't know how to use sscanf with strcmp..
*cries*
Would you be able to help me put the sscanf into it? would help alot! :3
AW: My cmd doesn't work? -
Blackazur - 21.01.2013
Read this maybe it will help you:
https://sampforum.blast.hk/showthread.php?tid=300397
Re: My cmd doesn't work? -
Oscii - 21.01.2013
The command in this topic isn't zcmd and I'm not planning on converting YET! :P
Re: My cmd doesn't work? -
[XST]O_x - 21.01.2013
https://sampforum.blast.hk/showthread.php?tid=310815
Re: My cmd doesn't work? -
DaRk_RaiN - 21.01.2013
Start using ZCMD its now or never.
pawn Код:
CMD:sethuman(playerid, params[])
{
if(PlayerInfo[playerid][jAdmin] < 3) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");//Checking if the player has admin level 3, if not it sends him a message.
new targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "{FF8000}/SetHuman {FF0000}[PlayerID/PartOfName]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player not connected!");
else
{
format(string, sizeof(string), "%s has set you to human.", PlayerName(playerid));
SendClientMessage(targetid, BLANCO, string);
gTeam[targetid] = EHUMAN;
HumanTeamCambia(targetid);
PlayerInfo[targetid][jZombie] = 0;
PlayerInfo[targetid][jInfected] = 0;
}
return 1;
}