27.01.2015, 10:44
~Load Armory System
Introduction
Hello everybody, today i will make an load armory system.
This system include three commands, /loadarmory and /unloadarmory and /armory , when you /loadarmory you will load weapons for cops and unload them so you can take guns from the armory, everytime the armory is empty you must load it again,and /armory to take ur guns.
~this system recommended to rp servers
Setups:
First Setup:
First thing to avoid "undfined PlayerInfo" error you must do this:
pawn Код:
enum pInfo
{
pTruckRefilled,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
enum armassets
{
M4,
COMBAT,
MP5,
ARMOR,
}
new Armory[armassets];
pawn Код:
#define DEF_M4COUNT 15
#define DEF_COMBATCOUNT 15
#define DEF_MP5COUNT 15
#define DEF_ARMORCOUNT 15
pawn Код:
Armory[MP5] = 15;
Armory[M4] = 15;
Armory[COMBAT] = 15;
Armory[ARMOR] = 15;
okey, in this setup we will make the commands.
First command /loadarmory:
pawn Код:
CMD:loadarmory(playerid, params[]) // this is the way you use since you are using zcmd include.
{
if(!IsACop(playerid))return SendClientMessage(playerid, COLOR_GREY, "You aren't a cop to use this command."); // this will check if the typer is a cop, [change it to your function]
if(!IsPlayerInRangeOfPoint(playerid, 2.7, 2209.6809,925.5018,10.8203)) return SendClientMessage(playerid, COLOR_GREY, "You aren't near armory equipment loading place."); // this checks if the player is at loading place [ change the postion if you don't like]
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 433 && GetVehicleModel(GetPlayerVehicleID(playerid)) == 427) return SendClientMessage(playerid, COLOR_GREY, "You are not in a barracks or enforcer."); // this checks which car are you using, change the id if you won't this cars [this added so you won't load equipments with an NRG or somthing xd]
if(PlayerInfo[playerid][pTruckRefilled] == 1) return SendClientMessage(playerid, COLOR_GREY, "You already loaded the truck."); // this checks if you already refilled or not, if you already loaded you won't be able to load again.
{
PlayerInfo[playerid][pTruckRefilled] = 1; // this will tell the script you loaded the truck so you won't load again.
SendClientMessage(playerid, COLOR_GREY, "You loaded the truck with Armory equipments."); // this will send a message to the typer [ change it to what you like].
}
return 1;
}
pawn Код:
CMD:unloadarmory(playerid, params[]) // this is the way you use since you are using zcmd include.
{
if(!IsACop(playerid))return SendClientMessage(playerid, COLOR_GREY, "You aren't a cop to use this command."); // this will check if the typer is a cop, [change it to your function]
if(!IsPlayerInRangeOfPoint(playerid, 2.7,1525.7316,-1677.5465,5.8906)) return SendClientMessage(playerid, COLOR_GREY, "You aren't near armory equipment unloading place."); // this unloading postion, change it to where u like.
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 433 && GetVehicleModel(GetPlayerVehicleID(playerid)) == 427) return SendClientMessage(playerid, COLOR_GREY, "You are not in a barracks or enforcer."); // this checks which car are you using, change the id if you won't this cars [this added so you won't load equipments with an NRG or somthing xd]
if(PlayerInfo[playerid][pTruckRefilled] == 0) return SendClientMessage(playerid, COLOR_GREY, "You didn't load the truck with armory equipments."); // this checks if you loaded or not.
{
PlayerInfo[playerid][pArmoryRefilled] = 0; // this makes you unloaded so you can't /unload again until u /load.
SendClientMessage(playerid, COLOR_GREY, "You refilled the equipment armory ."); // this will sends a message when you /unload change it to w/e u want
Armory[M4] = 15; // this makes the armory have 15 guns with m4.
Armory[COMBAT] = 15; // this makes the armory have 15 guns with combat.
Armory[MP5] = 15; // this makes the armory have 15 guns with mp5.
Armory[ARMOR] = 15; // this makes the armory have 15 armory equipmnets.
}
return 1;
}
Let's start with /armory command.
pawn Код:
CMD:armory(playerid, params[])
{
if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You aren't a cop to use this command."); // this checks if you are cop, change to ur function.
if(!IsPlayerInRangeOfPoint(playerid, 2.7,256.2174,77.3295,1004.0344)) return SendClientMessage(playerid, COLOR_GREY, "You aren't near your locker."); // this checks if the player is at his locker, change the postion to where u want.
{
ShowDialog(playerid, 501); // this will show the dialog, mp5, combat, m4 and armor.
}
return 1;
}
add this under public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
pawn Код:
else if(dialogid == 501)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(Armory[MP5] <= 0) return SendClientMessage(playerid, COLOR_GREY, "The mp5 armory is empty."); // this checks if the armory is empty from mp5 or its have.
{
GiveZaiatWeapon(playerid, 29, 250); // this will give you a mp5 with 250 bullets.
Armory[MP5]--; // this will remove one gun eachtime you take mp5
}
}
case 1:
{
if(Armory[M4] <= 0) return SendClientMessage(playerid, COLOR_GREY, "The m4 armory is empty.");
{
GiveZaiatWeapon(playerid, 31, 250);
Armory[M4]--;
}
}
case 2:
{
if(Armory[COMBAT] <= 0) return SendClientMessage(playerid, COLOR_GREY, "The Combat armory is empty.");
{
GiveZaiatWeapon(playerid, 27, 250);
Armory[COMBAT]--;
}
}
case 3:
{
if(Armory[ARMOR] <= 0) return SendClientMessage(playerid, COLOR_GREY, "The Armor equipment is empty.");
{
SetPlayerArmour(playerid, 100);
Armory[ARMOR]--;
}
}
}
}
pawn Код:
case 501: // armory sapd
{
ShowPlayerDialog(playerid, 501, DIALOG_STYLE_LIST, "{42C2F5}SAPD armory", "Mp5\nM4\nCombat\nArmor", "Choose", "Cancel");
}
thanks Zeex for zcmd
and i hope i explained pretty well, sorry for bad english.