PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success){
if (PlayerInfo[playerid][LoggedIn] == false) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this."), 0;
return 1;
}
getUserName(pid){
new s[24];
GetPlayerName(pid,s,24);
GiveNameSpace(s);
return s;
}
getWeaponName(wid){
new s[32];
GetWeaponName(wid,s,32);
return s;
}
GivePlayerWeaponEx(playerid, weaponid, ammo)
{
switch(weaponid){
case 2..15:{
SetPVarInt(playerid, "MeeleWeapon", weaponid);
if(GetPVarInt(playerid, "MeeleWeapon") < 0) SetPVarInt(playerid, "MeeleWeapon", 0);
GivePlayerWeapon(playerid, weaponid, 1);
}
case 22..24,28..29:{
SetPVarInt(playerid, "SecondaryWeapon", weaponid);
SetPVarInt(playerid, "SecondaryWeaponAmmo", ammo);
if(GetPVarInt(playerid, "SecondaryWeapon") < 0) SetPVarInt(playerid, "SecondaryWeapon", 0);
GivePlayerWeapon(playerid, weaponid, ammo);
}
case 25..27,30..34:{
SetPVarInt(playerid, "PrimaryWeapon", weaponid);
SetPVarInt(playerid, "PrimaryAmmo", ammo);
if(GetPVarInt(playerid, "PrimaryWeapon") < 0) SetPVarInt(playerid, "PrimaryWeapon", 0);
GivePlayerWeapon(playerid, weaponid, ammo);
}
default:{
SendClientMessage(playerid, COLOR_ORANGE, "Error: That weapon isn't part of the script or can be bought at a 24/7");
}
}
return 1;
}
COMMAND:giveweapon(playerid, params[])
{
if(GetPVarInt(playerid, "Admin") < 3)return SendClientMessage(playerid, COLOR_GREY, "You are not admin!");
new targetid,weaponid,ammo;
if(sscanf(params, "uii", targetid, weaponid, ammo)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /giveweapon [player] [weapon] [ammo]");
if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "This player is not connected !");
//giving weapon : changed playerid to targetid
GivePlayerWeaponEx(targetid,weaponid,ammo);
//message for players
format(s,90,"Server: %s has given %s to %s.",getUserName(playerid),getWeaponName(weaponid),getUserName(targetid));
SendAdminMessage(COLOR_ORANGE, s);
AdminLog(playerid,"giveweapon",s);
return 1;
}