Код:
if(strcmp(cmd, "/give", true) == 0) // by Ellis
{
if(IsPlayerConnected(playerid))
{
new x_nr[256];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /give [name] [playerid/PartOfName] ([ammount])");
SendClientMessage(playerid, COLOR_WHITE, "Available names: gun");
return 1;
}
if(strcmp(x_nr,"gun",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give gun [playerid/PartOfName]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(ProxDetectorS(5.0, playerid, giveplayerid))
{
new playergun;
new playerammo;
playergun = GetPlayerWeapon(playerid);
playerammo = GetPlayerAmmo(playerid);
if(playergun < 1)
{
SendClientMessage(playerid, COLOR_GREY, " You don't have a weapon !");
return 1;
}
if(playerammo < 1)
{
SendClientMessage(playerid, COLOR_GREY, " You don't have ammo !");
return 1;
}
if(playergun > 0)
{
GivePlayerWeapon(playerid, playergun, -playerammo);
GivePlayerWeapon(giveplayerid, playergun, playerammo);
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
format(string,sizeof(string), " %s has given you a weapon", sendername);
SendClientMessage(giveplayerid, COLOR_ARGOGREEN, string);
format(string,sizeof(string), " You have given %s a weapon", giveplayer);
SendClientMessage(playerid, COLOR_ARGOGREEN, string);
format(string, sizeof(string), "* %s has given %s a weapon.", sendername ,giveplayer);
ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Player is not near you ! ");
return 1;
}
}
}
}
else
{
return 1;
}
}
return 1;
}
Yes it gives a weap to the player (but with your amount of ammo) and removes from your slot.
Not really what I looked for...Suppose to be for players and not admins like if im not holding a M4 it will say You dont have a gun , If I have a m4 with 500 ammo and i do /give gun ID amount , amout being 200 , It should give that player 200 M4 ammo and subtract 200 ammo from me