#include <a_samp>//you all know that.
#include <zcmd>//including the zcmd include in the script.
#if defined FILTERSCRIPT
#else
#endif
enum invInfo{
weaponname,//the variable which would store the weapon ids.
weaponammo//the variable which would store the weapon ammo.
}
new PlayerInfo[MAX_PLAYERS][invInfo];
forward Weapondata(playerid);//the forward the the public in the next line.
public Weapondata(playerid)//making a cmd for the next commands.
{
new string[200];//the variable which will store the text to send to the player.
{
PlayerInfo[playerid][weaponname] = GetPlayerWeapon(playerid);//this is used to store the players weapon id in the variable
PlayerInfo[playerid][weaponammo] = GetPlayerAmmo(playerid);//this is used to store the players weapon ammo in the variable
format(string,sizeof(string),"You have gun with id %i and %d ammo!",weaponname,weaponammo);//formating the message which will be sent to the player.
SendClientMessage(playerid,-1,string);//sending the formated message.
}
}
forward Storeweaponininv(playerid);//the forward the the public in the next line.
public Storeweaponininv(playerid)//making a cmd for the next commands.
{
new string[200];//the variable which will store the text to send to the player.
{
PlayerInfo[playerid][weaponname] = GetPlayerWeapon(playerid);//this is used to store the players weapon id in the variable "weaponname".
PlayerInfo[playerid][weaponammo] = GetPlayerAmmo(playerid);//this is used to store the players weapon ammo in the variable "weaponammo".
format(string,sizeof(string),"You have gun with id %i with %d ammo stored in your bag!",weaponname,weaponammo);//will format the message and store it in the variable "string".
SendClientMessage(playerid,-1,string);//this will send the text stored in the variable "string".
ResetPlayerWeapons(playerid);//this will remove player's weapon that was to be stored in the variables("weaponname""weaponammo")
}
}
forward takeweaponfrominv(playerid);//the forward the the public in the next line.
public takeweaponfrominv(playerid)//making a cmd for the next commands.
{
new string[200];//the variable which will store the text to send to the player.
format(string,sizeof(string),"You have taken gun with the id %i and %d ammo from the bag!",weaponname,weaponammo);//will format the message and store it in the variable "string".
SendClientMessage(playerid,-1,string);//this will send the text stored in the variable "string".
GivePlayerWeapon(playerid,weaponname,weaponammo);//this will give player the same weapon with the same ammo.
PlayerInfo[playerid][weaponname] = 0;
PlayerInfo[playerid][weaponammo] = 0;
}
CMD:weapondata(playerid,params[])//cmd to check the weapon data.
{
Weapondata(playerid);//sending the data we collected above.
return 1;
}
CMD:storewininv(playerid,params[])//the cmd to store the gun in the inventory.
{
Storeweaponininv(playerid);//storing all the data of the gun in a variable and removing player's weapon.
return 1;
}
CMD:takewfrinv(playerid,params[])//cmd to take the gun out of the inventory.
{
if(PlayerInfo[playerid][weaponammo] == 0 || PlayerInfo[playerid][weaponname] == 0)return SendClientMessage(playerid,-1,"You do not have a weapon in you bag!");//this will check that if he has a weapon in the bag,if he does not have any weapon,it will give him an error message.
takeweaponfrominv(playerid);//this will get all the stored information and give the player back his weapon with the same ammo.
return 1;
}
This is not "inventory system" its like tempory pocket when you rester/get kicked/.... lost connection to server everything you have its pfff gone ,if you have make it to be save that it that will be ok but this ... noone will use it
|
This is not "inventory system" its like tempory pocket when you rester/get kicked/.... lost connection to server everything you have its pfff gone ,if you have make it to be save that it that will be ok but this ... noone will use it
|
This isn't a saving tutorial... It's a tutorial on how to make a weapon inventory system
|
define your meaning of word : inventory
" Inventory is word wich mean storing something on place" - wikipedia |