SA-MP Forums Archive
GivePlayerWeapon (id) (weaponid) (ammo) - 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: GivePlayerWeapon (id) (weaponid) (ammo) (/showthread.php?tid=420102)



GivePlayerWeapon (id) (weaponid) (ammo) - Youtube12 - 03.03.2013

Hi guys, who can help me to do "/giveplayerweapon" command using strtok?

Thx


Re: GivePlayerWeapon (id) (weaponid) (ammo) - Jstylezzz - 03.03.2013

Place this under your OnPlayerCommandText
pawn Код:
if(strcmp(cmd,"/giveweapon",true) == 0)//check if the player does the command
{
    new target,weapon,ammo;//define the variables
    if(sscanf(params,"iii",target,weapon,ammo)) return SendClientMessage(playerid,0x0FFFFFF,"Usage: /giveweapon [playerid][weaponid][ammo]");//check if the player typed all the params
    GivePlayerWeapon(target,weapon,ammo);//give the target the gun and ammo
    SendClientMessage(playerid,0x0FFFFFF,"You gave the player a gun.");//send a confirmation to the player that the command was succesfull
    SendClientMessage(target,0x0FFFFFF,"You have received a gun");//let the target know he received a gun
    return 1;
}
You will need sscanf for this command.
I just made it in a minute, so I'm not sure if it works.

EDIT: I added comments to it so you know what I'm doing, and WHY I'm doing it.
Try to understand what and why I'm doing things, so you can learn to make it yourself


AW: GivePlayerWeapon (id) (weaponid) (ammo) - Youtube12 - 03.03.2013

I get 1 Error:
Код:
error 017: undefined symbol "params"



Re: GivePlayerWeapon (id) (weaponid) (ammo) - Jstylezzz - 03.03.2013

My bad, that's the sscanf thing for the ZCMD commands..
I will try to find something for the strcmp version, I will edit this post if I find something.

EDIT: I checked some scripts and I see they do something with strlen();
I'm going for dinner now, I'll be back later


AW: GivePlayerWeapon (id) (weaponid) (ammo) - Youtube12 - 03.03.2013

Yes pls dont forget me and thx