20.01.2019, 18:51
So I made a custom weapon giving function for my anti-cheat but the /giveweapon command isn't working. In the giveweapon function after typing /giveweapon 0 24 50 it says
SendClientMessage(playerid, COLOR_ORANGE, "Error: That weapon isn't part of the script or can be bought at a 24/7");
SendClientMessage(playerid, COLOR_ORANGE, "Error: That weapon isn't part of the script or can be bought at a 24/7");
Code:
COMMAND:giveweapon(playerid, params[]) { new targetid,weaponid,ammo; if(sscanf(params, "uii", targetid, weaponid, ammo)) SendClientMessage(playerid, COLOR_GREY, "USAGE: /giveweapon [player] [weapon] [ammo]"); else { if (PlayerInfo[playerid][LoggedIn] == false) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this."); if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "This player is not connected !"); if(IsPlayerNPC(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Can't do this to a NPC."); if (GetPVarInt(playerid, "Jailed") != 0) return true; if(GetPVarInt(playerid, "Admin") >= 3) { new gunname[32]; new sendername[24]; new pName[24]; new str1[128]; GetPlayerName(playerid, pName, 24); GetPlayerName(targetid, sendername, 24); GiveNameSpace(pName); GiveNameSpace(sendername); GetWeaponName(weaponid, gunname, sizeof(gunname)); format(str1, sizeof(str1), "Server: %s has given %s a %s.", pName, gunname, sendername); SendAdminMessage(COLOR_ORANGE, str1); GivePlayerWeaponEx(playerid, weaponid, ammo); AdminLog(playerid,"giveweapon",str1); } else { SendClientMessage(playerid, COLOR_RED, "You do not have access to this command !"); } } return 1; } stock GivePlayerWeaponEx(playerid, weaponid, ammo) { if(weaponid >= 2 && weaponid <= 15) { SetPVarInt(playerid, "MeeleWeapon", weaponid); if(GetPVarInt(playerid, "MeeleWeapon") < 0) SetPVarInt(playerid, "MeeleWeapon", 0); GivePlayerWeapon(playerid, weaponid, 1); return 1; } if(weaponid >= 22 && weaponid <= 24 && weaponid >= 28 && weaponid <= 29) { SetPVarInt(playerid, "SecondaryWeapon", weaponid); SetPVarInt(playerid, "SecondaryWeaponAmmo", ammo); if(GetPVarInt(playerid, "SecondaryWeapon") < 0) SetPVarInt(playerid, "SecondaryWeapon", 0); GivePlayerWeapon(playerid, weaponid, ammo); return 1; } if(weaponid >= 25 && weaponid <= 27 && weaponid >= 30 && weaponid <= 34) { SetPVarInt(playerid, "PrimaryWeapon", weaponid); SetPVarInt(playerid, "PrimaryAmmo", ammo); if(GetPVarInt(playerid, "PrimaryWeapon") < 0) SetPVarInt(playerid, "PrimaryWeapon", 0); GivePlayerWeapon(playerid, weaponid, ammo); return 1; } SendClientMessage(playerid, COLOR_ORANGE, "Error: That weapon isn't part of the script or can be bought at a 24/7"); return true; }