Easy Question - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Easy Question (
/showthread.php?tid=135153)
Easy Question -
playbox12 - 19.03.2010
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.
Re: Easy Question -
MaykoX - 19.03.2010
Here is mistake : GivePlayerWeapon(playerid,weaponid,
100); You need to make it that it saves an ammo too...
Re: Easy Question -
MaykoX - 19.03.2010
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
Re: Easy Question -
playbox12 - 19.03.2010
What do i need to put under LoadWeaponsToFile
Re: Easy Question -
playbox12 - 19.03.2010
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??
Re: Easy Question -
dice7 - 19.03.2010
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);
Re: Easy Question -
playbox12 - 19.03.2010
Thanks you both, it works now!!
Thanks, again..