Easy Question
#1

Hi,

I know this should be easy but i am new with dini, and i am trying to fix the follow.

When you buy an weapon you get 100 bullets, when you shoot 10 bullets you have 90, but when you log off, and back on. You have 100 bullets again, so what i want is that you buy an weapon with 100 bullets you shoot 10 bullets then you have 90 i want that it saves the 90 bullets and when you log back on you have 90 bullets. Please help it would be much apreciated

Regards,


- Jeroen

PS: you will need the code so:

Код:
SaveWeaponsToFile(playerid)
{
	new i, path[128], string[256], weaponid, ammo;
  path = GetPlayerFormattedName(playerid);
  if (!dini_Exists(path)) dini_Create(path);
	for (i=0; i<13; i++)
	{
	  GetPlayerWeaponData(playerid,i,weaponid,ammo);
	  format(string,sizeof(string),"Weapon - %d",i);
	  dini_IntSet(path,string,weaponid);
	}
}

public LoadWeaponsToFile(playerid)
{
	new i, path[128], string[256], weaponid;
  path = GetPlayerFormattedName(playerid);
  ResetPlayerWeapons(playerid);
	for (i=0; i<13; i++)
	{
	  format(string,sizeof(string),"Weapon - %d",i);
	  weaponid = dini_Int(path,string);
	  GivePlayerWeapon(playerid,weaponid,100);
	}
	AlreadyGiveWeapons[playerid] = true;
}

public RemoveWeaponsFile(playerid)
{
	new path[128];
	path = GetPlayerFormattedName(playerid);
	dini_Remove(path);
}
Need some more just tell me, thanks for the time and help.
Reply
#2

Here is mistake : GivePlayerWeapon(playerid,weaponid,100); You need to make it that it saves an ammo too...
Reply
#3

Quote:
Originally Posted by † мąүқоҳ™
Here is mistake : GivePlayerWeapon(playerid,weaponid,100); You need to make it that it saves an ammo too...
anyway here is code :

Quote:

SaveWeaponsToFile(playerid)
{
new i, path[50], string[128], weaponid, ammo;
path = GetPlayerFormattedName(playerid);
if (!dini_Exists(path)) dini_Create(path);
for (i=0; i<13; i++)
{
GetPlayerWeaponData(playerid,i,weaponid,ammo);
format(string,sizeof(string),"Weapon - %d",i);
dini_IntSet(path,string,weaponid);
format(string,sizeof(string),"AmmoID - %d",i);
dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);
}
}

EDIT : WOPS I PUSHED QUOTE !!! FAIL
Reply
#4

What do i need to put under LoadWeaponsToFile
Reply
#5

Quote:
Originally Posted by † мąүқоҳ™
Quote:
Originally Posted by † мąүқоҳ™
Here is mistake : GivePlayerWeapon(playerid,weaponid,100); You need to make it that it saves an ammo too...
anyway here is code :

Quote:

SaveWeaponsToFile(playerid)
{
new i, path[50], string[128], weaponid, ammo;
path = GetPlayerFormattedName(playerid);
if (!dini_Exists(path)) dini_Create(path);
for (i=0; i<13; i++)
{
GetPlayerWeaponData(playerid,i,weaponid,ammo);
format(string,sizeof(string),"Weapon - %d",i);
dini_IntSet(path,string,weaponid);
format(string,sizeof(string),"AmmoID - %d",i);
dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);
}
}

EDIT : WOPS I PUSHED QUOTE !!! FAIL
Maykox what do i need to put under LoadWeaponsToFile or keep it as it is??
Reply
#6

pawn Код:
format(string,sizeof(string),"Weapon - %d",i);
weaponid = dini_Int(path,string);
format(string,sizeof(string),"AmmoID - %d",i);
int ammo = dini_Int(path, string);
GivePlayerWeapon(playerid,weaponid,ammo);
Reply
#7

Thanks you both, it works now!!




Thanks, again..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)