05.08.2010, 05:25
Use dini instead.
Add this at the top of your script:
Under /minigundm, add
Copy / paste this somewhere into your script, at the complete bottom is fine.
now under public OnPlayerDeath, add
The functions are not made by me, only edited. It does work for me, hope it does for you. Good luck.
Add this at the top of your script:
pawn Код:
#define PATH "Weapons" // Folder where a player's weapons will save
pawn Код:
SaveWeaponsToFile(playerid);
pawn Код:
SaveWeaponsToFile(playerid)
{
new i, path[50], string[128], weaponid, ammo;
path = GetPlayerFormattedName(playerid);
if (!dini_Exists(path)) dini_Create(path);
for (i=1; 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);
dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);
}
}
GetPlayerFormattedName(playerid)
{
new name[24], full[50];
GetPlayerName(playerid,name,sizeof(name));
format(full,sizeof(full),"%s/%s.txt",PATH,name);
return full;
}
forward LoadWeaponsToFile(playerid);
public LoadWeaponsToFile(playerid)
{
new i, path[50], string[128], weaponid, ammo;
path = GetPlayerFormattedName(playerid);
ResetPlayerWeapons(playerid);
for (i=1; i<13; i++)
{
format(string,sizeof(string),"Weapon - %d",i);
weaponid = dini_Int(path,string);
format(string,sizeof(string),"AmmoID - %d",i);
ammo = dini_Int(path,string);
GivePlayerWeapon(playerid,weaponid,ammo);
SetTimerEx("LoadWeaponsToFile2", 2000, 0, "i", playerid);
}
}
pawn Код:
SetTimerEx("LoadWeaponsToFile",250,false,"i",playerid