View Full Version : GivePlayerWeapon (id) (weaponid) (ammo)

03/03/2013, 03:57 PM
Hi guys, who can help me to do "/giveplayerweapon" command using strtok?


03/03/2013, 04:04 PM
Place this under your OnPlayerCommandText

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

03/03/2013, 04:08 PM
I get 1 Error:
error 017: undefined symbol "params"

03/03/2013, 04:13 PM
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

03/03/2013, 04:14 PM
Yes pls dont forget me :) and thx