15.11.2011, 11:09
pawn Код:
stock SaveWeapons(playerid)
{
new pharrel[128], string_[29], weapon, ammo;
for(new i=0; i<13; i++)
{
GetPlayerWeaponData(playerid, i, weapon, ammo);
format(string_, 5,"%d%d",weapon,ammo);
strcat(pharrel, string_);
}
GetPlayerName(playerid, string_, 24);
format(string_, 29, "%s.ini", string_);
new File:arquivo = fopen(string_, io_read);
fwrite(arquivo, pharrel);
fclose(arquivo);
return 1;
}
stock LoadWeapons(playerid)
{
new string_[29], pharrel[128], weapon[13], ammo[13];
format(string_, 29, "%s.ini", string_);
new File:arquivo = fopen(string_, io_read);
fread(arquivo, pharrel, 128);
fclose(arquivo);
fremove(arquivo);
unformat(pharrel, "dddddddddddddddddddddddd",
weapon[0],ammo[0],weapon[1],ammo[1],weapon[2],ammo[2],weapon[3],ammo[3],weapon[4],ammo[4],weapon[5],ammo[5],weapon[6],
ammo[6],weapon[7],ammo[7],weapon[8],ammo[8],weapon[9],ammo[9],weapon[10],ammo[10],weapon[11],ammo[11],weapon[12],ammo[12]);
for(new i=0; i<13; i++)
{
if(ammo[i] > 0);
GivePlayerWeapon(playerid, weapon[i], ammo[i]);
}
return 1;
}
vc vai precisar do plugin sscanf2
Se vc quiser salvar as armas de todos os players em 1 sу file eu aconselho a usar SII, se vc quiser eu faзo pra vc.