How to make this possible
#1

Hello guys well i am trying to make some sort of System like a Safe or locker for players in my server

lets say

/safe and they will have the option to save Different Stuff under the same File or Variable for Example
Money Drugs Weapons

what is the best way to make this ? i belive Arrays? but im not so good with them so could someone Explain it to me a bit thanks
Reply
#2

Код:
	new tstr[20];
	new tammo, tweap;
	for(new w=0; w<12; w++)
	{
		GetPlayerWeaponData(playerid,w,tweap,tammo);
		format(tstr,sizeof(tstr),"wslot%d",w);
		dini_IntSet(file, tstr, GetPVarInt(playerid,tstr));
		format(tstr,sizeof(tstr),"wammo%d",w);
		if(tammo == -1)
		{
			format(tstr,sizeof(tstr),"sammo%d",w);
			tammo = GetPVarInt(playerid,tstr);
			format(tstr,sizeof(tstr),"wammo%d",w);
		}
		dini_IntSet(file, tstr, tammo);
	}
this is for if you save your weapons to a PVar called wslot[slotid] like wslot1 or wslot3 and ammo to wamma[slotid]
if wammo[slotid] == -1 (meaning it doesn't return properly then it'll put it to 50 ammo.
so I also run a timer to constantly get the ammo so it returns a more precise ammo, that timer saves the ammo data to sammo[slotid]

Код:
public smartammo()
{
	for(new i=0;i<MAX_PLAYERS;i++)
	{
		new tstr[20];
		new tammo, tweap;
		for(new w=0; w<12; w++)
		{
			GetPlayerWeaponData(i,w,tweap,tammo);
			format(tstr,sizeof(tstr),"sammo%d",w);
			if(tammo != -1)
			{
				SetPVarInt(i,tstr,tammo);
			}
			if(tammo == -1 && GetPVarInt(i,tstr) == 0)
			{
				SetPVarInt(i,tstr,50);
			}
		}
	}
}
Reply
#3

Well i know how to store them ?
the thing is it possible to save different stuff like Money Guns or Drugs under the same variable example

Stats[playerid][Inventory] = Gun/money/drugs;

not all at the same time just once but yeah
Reply
#4

If you save them at the same line, you would have to put all thier money,guns, etc into the file at the same time as it just overwrites that line.. So you wouldn't be able to like put some money into it without your weapons i believe.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)