Inventory system [+REP]
#1

Hey, i'm trying to make a inventory system for my server, i'm working to make this inventory system works when i buy a weapon from any weapon shop it saves the weapon which i bought to my inventory or also when i buy a medkit it saves to my inventory.

So what i need is how to make a cmd to make show a dialog menu showing all the weapon names i bought from the shop and saved from my inventory.

Here is some codes which i made that may help you for making that for me
Код:
new Bat[MAX_PLAYERS];
new Knuckles[MAX_PLAYERS];
new Grenades[MAX_PLAYERS];
new p9mm[MAX_PLAYERS];
new Shotgun[MAX_PLAYERS];
new MP5[MAX_PLAYERS];
new Tec9[MAX_PLAYERS];
new HalfArmour[MAX_PLAYERS];
new RPG[MAX_PLAYERS];
new Knife[MAX_PLAYERS];
new Molotov[MAX_PLAYERS];
new sdPistol[MAX_PLAYERS];
new SawnOffShotgun[MAX_PLAYERS];
new MicroUzi[MAX_PLAYERS];
new M4[MAX_PLAYERS];
new CountryRifle[MAX_PLAYERS];
new FullArmour[MAX_PLAYERS];
new Minigun[MAX_PLAYERS];
new Kantana[MAX_PLAYERS];
new SatchelCharges[MAX_PLAYERS];
new DesertEagle[MAX_PLAYERS];
new CombatShotgun[MAX_PLAYERS];
new AK47[MAX_PLAYERS];
new Sniper[MAX_PLAYERS];
new FlameThrower[MAX_PLAYERS];
Код:
if(dialogid == ammudiag1)
	{
		if(response)
		{
		    if(listitem == 0)
		    {
				if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
				if(Bat[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
		        Bat[playerid] = 1;
		        GivePlayerMoney(playerid,-1500);
		        SendClientMessage(playerid,0x2D9578FF,"You have added the Baseball Bat to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Bat",Bat[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 1)
		    {
		    	if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(Knuckles[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                Knuckles[playerid] = 1;
                GivePlayerMoney(playerid,-2000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Brass Knuckles to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Knuckles",Knuckles[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 2)
		    {
				if(GetPlayerMoney(playerid) < 7000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
                GivePlayerMoney(playerid,-7000);
                Grenades[playerid] = 7;
                SendClientMessage(playerid,0x2D9578FF,"You have added +7 Grenades to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Grenades",Grenades[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 3)
		    {
		        if(GetPlayerMoney(playerid) < 15000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(p9mm[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                p9mm[playerid] = 1;
                GivePlayerMoney(playerid,-15000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the 9mm to your bag.");
                new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"9mm",p9mm[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 4)
		    {
		        if(GetPlayerMoney(playerid) < 32000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(Shotgun[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                Shotgun[playerid] = 1;
                GivePlayerMoney(playerid,-32000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Shotgun to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Shotgun",Shotgun[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 5)
		    {
		        if(GetPlayerMoney(playerid) < 37000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(MP5[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                MP5[playerid] = 1;
                GivePlayerMoney(playerid,-37000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the MP5 to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"MP5",MP5[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 6)
		    {
		        if(GetPlayerMoney(playerid) < 32000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(Tec9[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                Tec9[playerid] = 1;
                GivePlayerMoney(playerid,-32000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Tec9  to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Tec9",Tec9[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 7)
		    {
		        if(GetPlayerMoney(playerid) < 5000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(HalfArmour[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                HalfArmour[playerid] = 1;
                GivePlayerMoney(playerid,-5000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Half Armour to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"HalfArmour",HalfArmour[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 8)
		    {
		        if(GetPlayerMoney(playerid) < 530000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(RPG[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                RPG[playerid] = 1;
                GivePlayerMoney(playerid,-530000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the RPG to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"RPG",RPG[playerid]);
   	 			INI_Close(File);
		    }
		}
	}
	
	if(dialogid == ammudiag2)
	{
		if(response)
		{
		    if(listitem == 0)
		    {
		        if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(Knife[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                Knife[playerid] = 1;
                GivePlayerMoney(playerid,-10000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Knife to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Knife",Knife[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 1)
		    {
		        if(GetPlayerMoney(playerid) < 12000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
				GivePlayerMoney(playerid,-12000);
                Molotov[playerid] = 7;
                SendClientMessage(playerid,0x2D9578FF,"You have added +7 Molotovs to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Molotov",Molotov[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 2)
		    {
		        if(GetPlayerMoney(playerid) < 23000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
				if(sdPistol[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                sdPistol[playerid] = 1;
                GivePlayerMoney(playerid,-23000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Silence Pistol to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"sdPistol",sdPistol[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 3)
		    {
		        if(GetPlayerMoney(playerid) < 83000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(SawnOffShotgun[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                SawnOffShotgun[playerid] = 1;
                GivePlayerMoney(playerid,-83000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Sawn Off Shotgun to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"SawnOffShotgun",SawnOffShotgun[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 4)
			{
		        if(GetPlayerMoney(playerid) < 58000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(MicroUzi[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                MicroUzi[playerid] = 1;
                GivePlayerMoney(playerid,-58000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Micro Uzi to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"MicroUzi",MicroUzi[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 5)
		    {
		        if(GetPlayerMoney(playerid) < 63000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(M4[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                M4[playerid] = 1;
                GivePlayerMoney(playerid,-63000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the M4 to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"M4",M4[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 6)
		    {
		        if(GetPlayerMoney(playerid) < 92000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(CountryRifle[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                CountryRifle[playerid] = 1;
                GivePlayerMoney(playerid,-92000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Country Rifle to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"CountryRifle",CountryRifle[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 7)
		    {
		        if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(FullArmour[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
                FullArmour[playerid] = 1;
                GivePlayerMoney(playerid,-10000);
                SendClientMessage(playerid,0x2D9578FF,"You have added the Full Armour to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"FullArmour",FullArmour[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 8)
		    {
		        if(GetPlayerMoney(playerid) < 760000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(Minigun[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
				Minigun[playerid] = 1;
				GivePlayerMoney(playerid,-760000);
				SendClientMessage(playerid,0x2D9578FF,"You have added the Minigun to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Minigun",Minigun[playerid]);
   	 			INI_Close(File);
		    }
		}
	}
	
	if(dialogid == ammudiag3)
	{
		if(response)
		{
		    if(listitem == 0)
		    {
		        if(GetPlayerMoney(playerid) < 40000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(Kantana[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
				Kantana[playerid] = 1;
				GivePlayerMoney(playerid,-40000);
				SendClientMessage(playerid,0x2D9578FF,"You have added the Kantana to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Kantana",Kantana[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 1)
		    {
		        if(GetPlayerMoney(playerid) < 50000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
				SatchelCharges[playerid] = 7;
				GivePlayerMoney(playerid,-50000);
				SendClientMessage(playerid,0x2D9578FF,"You have added +7 Satchel Charges to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"SatchelCharges",SatchelCharges[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 2)
		    {
		        if(GetPlayerMoney(playerid) < 70000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(DesertEagle[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
				DesertEagle[playerid] = 1;
				GivePlayerMoney(playerid,-70000);
				SendClientMessage(playerid,0x2D9578FF,"You have added the Desert Eagle to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"DesertEagle",DesertEagle[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 3)
		    {
		        if(GetPlayerMoney(playerid) < 170000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(CombatShotgun[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
				CombatShotgun[playerid] = 1;
				GivePlayerMoney(playerid,-170000);
				SendClientMessage(playerid,0x2D9578FF,"You have added the Combat Shotgun to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"CombatShotgun",CombatShotgun[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 4)
		    {
		        if(GetPlayerMoney(playerid) < 58000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(MicroUzi[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
				MicroUzi[playerid] = 1;
				GivePlayerMoney(playerid,-58000);
				SendClientMessage(playerid,0x2D9578FF,"You have added the Micro Uzi to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"MicroUzi",Bat[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 5)
		    {
		        if(GetPlayerMoney(playerid) < 150000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(AK47[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
				AK47[playerid] = 1;
				GivePlayerMoney(playerid,-150000);
				SendClientMessage(playerid,0x2D9578FF,"You have added the AK47 to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"AK47",AK47[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 6)
		    {
		        if(GetPlayerMoney(playerid) < 270000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(Sniper[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
				Sniper[playerid] = 1;
				GivePlayerMoney(playerid,-270000);
				SendClientMessage(playerid,0x2D9578FF,"You have added the Sniper to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"Sniper",Sniper[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 7)
		    {
		        if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(FullArmour[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
				FullArmour[playerid] = 1;
				GivePlayerMoney(playerid,-10000);
				SendClientMessage(playerid,0x2D9578FF,"You have added the Full Armour to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"FullArmour",FullArmour[playerid]);
   	 			INI_Close(File);
		    }
		    if(listitem == 8)
		    {
		        if(GetPlayerMoney(playerid) < 1000000) return SendClientMessage(playerid,RED,"You don't have enough money for that!");
		    	if(FlameThrower[playerid] == 1) return SendClientMessage(playerid,RED,"You already have this item in your inventory.");
				FlameThrower[playerid] = 1;
				GivePlayerMoney(playerid,-1000000);
				SendClientMessage(playerid,0x2D9578FF,"You have added the Flame Thrower to your bag.");
		      	new INI:File = INI_Open(Path(playerid));
    			INI_SetTag(File,"Player's Data");
   				INI_WriteInt(File,"FlameThrower",FlameThrower[playerid]);
   	 			INI_Close(File);
		    }
		}
	}
Reply
#2

B.U.M.P
Reply
#3

Quote:

new Bat[MAX_PLAYERS];
new Knuckles[MAX_PLAYERS];
new Grenades[MAX_PLAYERS];
new p9mm[MAX_PLAYERS];
new Shotgun[MAX_PLAYERS];
new MP5[MAX_PLAYERS];
new Tec9[MAX_PLAYERS];
new HalfArmour[MAX_PLAYERS];
new RPG[MAX_PLAYERS];
new Knife[MAX_PLAYERS];
new Molotov[MAX_PLAYERS];
new sdPistol[MAX_PLAYERS];
new SawnOffShotgun[MAX_PLAYERS];
new MicroUzi[MAX_PLAYERS];
new M4[MAX_PLAYERS];
new CountryRifle[MAX_PLAYERS];
new FullArmour[MAX_PLAYERS];
new Minigun[MAX_PLAYERS];
new Kantana[MAX_PLAYERS];
new SatchelCharges[MAX_PLAYERS];
new DesertEagle[MAX_PLAYERS];
new CombatShotgun[MAX_PLAYERS];
new AK47[MAX_PLAYERS];
new Sniper[MAX_PLAYERS];
new FlameThrower[MAX_PLAYERS];

What's this? Use a enum to hold player weapons instead, after this its all about logical and basic knowledgement related to pawn scripting.
Reply
#4

Quote:
Originally Posted by ipsLeon
Посмотреть сообщение
What's this? Use a enum to hold player weapons instead, after this its all about logical and basic knowledgeable related to pawn scripting.
Yea i know that but can i just get some tips that help me for doing this....?
Reply
#5

Why you do it like this1!!!!! it very mess up your server
Reply
#6

Well, i made on my DM server a place called "Home" where no deathmatches allowed there and he can buy food for energy, weapons and medkits in that place, so when he buy weapons or medkits it should be saved to his inventory immediately to prevent him to take the weapon and dm in that place and when he enter any deathmatch he can take the gun which he bought.
Thats my idea, if any one got any other idea tell me and help for doing it.
Reply
#7

PHP код:
enum Player_Weapons
{
    
Bat,
    
Knuckles,
    
Grenades,
    
p9mm,
    
Shotgun,
    
MP5,
    
Tec9,
    
HalfArmour,
    
RPG,
    
Knife,
    
Molotov,
    
sdPistol,
    
SawnOffShotgun,
    
MicroUzi,
    
M4,
    
CountryRifle,
    
FullArmour,
    
Minigun,
    
Kantana,
    
SatchelCharges,
    
DesertEagle,
    
CombatShotgun,
    
AK47,
    
Sniper,
    
FlameThrower
}
    
new 
PlayerWeaps[MAX_PLAYERS][Player_Weapons]; 
Reply
#8

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
PHP код:
enum Player_Weapons
{
    
Bat,
    
Knuckles,
    
Grenades,
    
p9mm,
    
Shotgun,
    
MP5,
    
Tec9,
    
HalfArmour,
    
RPG,
    
Knife,
    
Molotov,
    
sdPistol,
    
SawnOffShotgun,
    
MicroUzi,
    
M4,
    
CountryRifle,
    
FullArmour,
    
Minigun,
    
Kantana,
    
SatchelCharges,
    
DesertEagle,
    
CombatShotgun,
    
AK47,
    
Sniper,
    
FlameThrower
}
    
new 
PlayerWeaps[MAX_PLAYERS][Player_Weapons]; 
I have already edited that, thanks by the way.
Do anyone know how to make cmd to show what is in my inventory?
Reply
#9

Learned more about pawn . . .....

Learned how to use "If" in pawn
Reply
#10

Quote:
Originally Posted by SequenceCuz
Посмотреть сообщение
Learned more about pawn . . .....

Learned how to use "If" in pawn
Learn*
Non-useful reply, don't reply here again please.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)