GivePlayerWeapon (id) (weaponid) (ammo)
#1

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

Thx
Reply
#2

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
Reply
#3

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

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
Reply
#5

Yes pls dont forget me and thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)