Help - 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: Help (
/showthread.php?tid=552602)
Help -
Edw - 25.12.2014
Hello.
How can I do if when using / givegun and not put a parameter (eg / givegun ID) can not be used.
If yes / givegun defends his entire command id (id weapon bullets), I hope you understand.
I mean if you do not write complete command (/ givegun id weapon bullets) to the message does not appear again to be able to use the command
Excuse my English.
pawn Код:
if(strcmp(cmd, "/givegun", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 2)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_SERVER, "Foloseste: {FFFFFF}/givegun [playerid] [weapon] [gloante]");
return 1;
}
new GunID;
new Ammo;
PlayerID = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
GunID = strval(tmp);
tmp = strtok(cmdtext, idx);
Ammo = strval(tmp);
if(IsPlayerConnected(PlayerID))
{
if(PlayerID != INVALID_PLAYER_ID)
{
GivePlayerWeapon(PlayerID, GunID, Ammo);
}
}
}
}
return 1;
}
AW: Help -
Flori - 25.12.2014
I have no idea what you actually mean, but a look at your code was enought to see that you need to update to 'sscanf'.
https://sampwiki.blast.hk/wiki/Sscanf
Re: Help -
Ryz - 25.12.2014
pawn Код:
if(strcmp(cmd, "/givegun", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 2)
{
new id ,weap ,ammo;
if(sscanf(params, "uii",id,weap,ammo)) return SendClientMessage(playerid, -1, "/givegun [playerid] [weapon] [gloante]") ;
if(IsPlayerConnected(PlayerID))
{
if(PlayerID != INVALID_PLAYER_ID)
{
GivePlayerWeapon(id, weapid, ammo);
}
}
}
}
return 1;
}