15.12.2014, 19:09
How to make an admin give gun command, like example /givegun (ammo) (weapon id/name) ?
#include <sscanf2>
#include <zcmd>
CMD:giveweapon(playerid, params[])
{
new tmp[256];
new lookupid, weapon, wname[64], ammo;
if(IsPlayerAdmin(playerid))
{
if (sscanf(params, "uii",lookupid, weapon, ammo))
return SendClientMessage(playerid, COLOR_YELLOW, "/givewepon <playerid> <gunid> <ammo>");
if (!IsPlayerConnected(lookupid)) { return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected."); }
if (weapon < 1 || weapon > 46)
return SendClientMessage(playerid, COLOR_YELLOW, "Invalid weapon ID, valid id's are between 0 and 46");
GivePlayerWeapon(lookupid, weapon, ammo);
GetWeaponName(weapon, wname, 64);
format(tmp, sizeof(tmp), "Admin %s (ID:%d) gave %s (ID:%d) a %s with %d ammo", GetName(playerid), playerid, GetName(lookupid), lookupid, wname, ammo);
SendClientMessageToAll(COLOR_YELLOW, tmp);
format(tmp, sizeof(tmp), "Admin %s (ID:%d) gave you a %s with %d ammo", GetName(playerid), playerid, wname, ammo);
SendClientMessage(lookupid, COLOR_YELLOW, tmp);
}
return 1;
}
GetName
stock GetName(playerid)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
return PlayerName;
}
CMD:givegun(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
if(sscanf(params, "ud", target, gun)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /givegun <playerid> <gun>");
if(gun < 1 || gun > 47) return SendClientMessage(playerid, COLOR_GREY, "Don't go below 1 or above 47.");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_GREY, "User is not connected!");
if(gun != 21)
{
GivePlayerWeapon(target, gun, 50000); //Your version would be GivePlayerValidWeapon, this also may be causing issues.
format(string, sizeof(string), "Admin %s has given you a weapon.", GetName(playerid));
SendClientMessage(target, COLOR_GREY, string);
format(string, sizeof(string), "You have given %s a weapon.", GetName(target));
SendClientMessage(playerid, COLOR_GREY, string);
}
return 1;
}
(13833) : error 012: invalid function call, not a valid address (13833) : warning 215: expression has no effect (13833) : error 001: expected token: ";", but found ")" (13833) : error 029: invalid expression, assumed zero (13833) : fatal error 107: too many error messages on one line
format(tmp, sizeof(tmp), "Admin %s (ID:%d) gave %s (ID:%d) a %s with %d ammo", PlayerName(playerid), playerid, PlayerName(lookupid), lookupid, wname, ammo);
pawn Код:
|
(13818) : error 017: undefined symbol "target" (13819) : error 017: undefined symbol "gun" (13820) : error 017: undefined symbol "target" (13821) : error 017: undefined symbol "gun" (13823) : error 017: undefined symbol "target" (13824) : error 017: undefined symbol "string" C:\Users\Atti\Desktop\server\gamemodes\PPC_Trucking.pwn(13824) : error 017: undefined symbol "string"
new string[128], gun, target;
new string[128], targer, gun;