dcmd_shareammo(playerid, params[])
{
new id, ammound, wid;
if(sscanf(params, "ud", id, ammound)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/shareammo [ID/NAME] [AMMOUND]\"");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
if((wid = GetPlayerWeapon(playerid)) && 43 >= wid >= 16) return SendClientMessage(playerid, 0x00FF00AA, "Acquire a right weapon");
if(GetPlayerAmmo(playerid) < ammound) return SendClientMessage(playerid, 0x00FF00AA, "You dont have that much ammo");
new string[128];
format(string, sizeof string, "You got %d ammo ", ammound);
SendClientMessage(id, 0x00FF00AA, string);
format(string, sizeof string, "You gived %d ammo", ammound);
SendClientMessage(playerid, 0x00FF00AA, string);
wid = GetPlayerWeapon(playerid);
GivePlayerWeapon(playerid, wid, -ammound);
GivePlayerWeapon(id, wid, ammound);
return 1;
}
CMD:shareammo(playerid, params[])
{
new id, ammound, wid;
if(sscanf(params, "ud", id, ammound)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/shareammo [ID/NAME] [AMMOUND]\"");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
if((wid = GetPlayerWeapon(playerid)) && 43 >= wid >= 16) return SendClientMessage(playerid, 0x00FF00AA, "Acquire a right weapon");
if(GetPlayerAmmo(playerid) < ammound) return SendClientMessage(playerid, 0x00FF00AA, "You dont have that much ammo");
new string[128];
format(string, sizeof string, "You got %d ammo ", ammound);
SendClientMessage(id, 0x00FF00AA, string);
format(string, sizeof string, "You gived %d ammo", ammound);
SendClientMessage(playerid, 0x00FF00AA, string);
wid = GetPlayerWeapon(playerid);
GivePlayerWeapon(playerid, wid, -ammound);
GivePlayerWeapon(id, wid, ammound);
return 1;
}
|
Make sure that ZCMD command is outside of OnPlayerCommandText. ZCMD has to be outside all functions, you can add it to the end of your GM.
|
CMD:giveammo(playerid, params[])
{
new id, ammound, wid;
if(sscanf(params, "ud", id, ammound)) return SendClientMessage(playerid, 0xAFAFAFAA, "Usage: \"/giveammo [id/name] [ammount]\"");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xAFAFAFAA, "Player not found");
if((wid = GetPlayerWeapon(playerid)) && 43 >= wid >= 16) return SendClientMessage(playerid, 0x00FF00AA, "Acquire a right weapon");
if(GetPlayerAmmo(playerid) < ammound) return SendClientMessage(playerid, 0xAFAFAFAA, "You dont have that much ammo");
new string[128];
format(string, sizeof string, "You got %d ammo ", ammound);
SendClientMessage(id, 0x00FF00AA, string);
format(string, sizeof string, "You gived %d ammo", ammound);
SendClientMessage(playerid, 0x00FF00AA, string);
wid = GetPlayerWeapon(playerid);
GivePlayerWeapon(playerid, wid, -ammound);
GivePlayerWeapon(id, wid, ammound);
return 1;
}
CMD:giveammo(playerid, params[])
{
new id, ammound, wid;
if(sscanf(params, "ud", id, ammound)) return SendClientMessage(playerid, 0xAFAFAFAA, "Usage: \"/giveammo [id/name] [ammount]\"");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xAFAFAFAA, "Player not found");
if(wid >= 43 || wid <= 16) return SendClientMessage(playerid, 0x00FF00AA, "Acquire a right weapon");
if(GetPlayerAmmo(playerid) < ammound) return SendClientMessage(playerid, 0xAFAFAFAA, "You dont have that much ammo");
new string[128];
format(string, sizeof string, "You got %d ammo ", ammound);
SendClientMessage(id, 0x00FF00AA, string);
format(string, sizeof string, "You gived %d ammo", ammound);
SendClientMessage(playerid, 0x00FF00AA, string);
wid = GetPlayerWeapon(playerid);
SetPlayerAmmo(playerid,wid,ammound);
return 1;
}
|
pawn Код:
|
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
dcmd(shareammo, 9, cmdtext);
zcmd(shareammo, 9, cmdtext);