19.09.2015, 01:10
So, the code you need is this
I hope it works, as I didn't test it.
PHP код:
CMD:agiveweapon(playerid, params[])
{
new targetid, weapon, ammo;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFF, "You are not an rcon admin!");
if(sscanf(params, "udd", targetid, weapon, ammo)) return SendClientMessage(playerid, 0xFFFFFF, "Usage: /agiveweapon [playerid]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFF, "Player is not connected!");
if(weapon < 1 || weapon > 46) return SendClientMessage(playerid, COLOR_RED, "Valid weaponids are 1 - 46"); // Because weaponid 88 is not valid...
new string[75], pname[MAX_PLAYER_NAME]; // This is to get the TARGET name (optional)
GivePlayerWeapon(targetid, weapon, ammo); // This will give the weapon to the targetid
GetPlayerName(targetid, pname, MAX_PLAYER_NAME); // This is to get the TARGETS name
format(string, sizeof string, "%s has received the weapon!", pname); // format is to define a variable, pname is the TARGETS name
SendClientMessage(playerid, 0xFFFFFF, string); // The player who committed the cmd, gets the message from the format above
SendClientMessage(targetid, 0xFFFFFF, "You have received a weapon!"); // Why didn't I use format here either? well, because there's no variable to define
return 1;
}