I'm having problems loading data of saved weapons.
Sometimes a player has the ammount of ammo of other, e.g. I deposit only 1 ammo of RPG, when other joins the server now my ammo is 90!
Really for me is very hard fix this, because I think that all the script is right
Код:
new aRPG[MAX_PLAYERS];//Variable to store the ammo of a weapon
public OnPlayerLogin(playerid)//This is called from OnDialogResponse when the password is correct
{
INI_ParseFile(Account(playerid), "Load_Weapons_%s", .bExtra = true, .extra = playerid);
}
stock Account(playerid)
{
new Name[MAX_PLAYER_NAME+10];
GetPlayerName(playerid, Name, sizeof(Name));
format(Name, sizeof(Name), "Users/%s.sav", Name);
return Name;
}
forward Load_Weapons_Weapons(playerid, name[], value[]);
public Leer_Weapons_Weapons(playerid, name[], value[])
{
INI_Int("aRPG", aRPG[playerid]);
return 1;
}
YCMD:drpg(playerid, params[], help)
{
new ammo;
if(sscanf(params, "i", ammo))
return SendClientMessage(playerid, red, "<X> Use /drpg <ammo>");
if(!IsPlayerInBank[playerid])
return SendClientMessage(playerid, red, "<X> You must be in a bank");
new eWeapon;
new eAmmo;
GetPlayerWeaponData(playerid, 7, eWeapon, eAmmo);
if(eWeapon == 35 && eAmmo >= ammo && ammo > 0)
{
if(EPInfo[playerid][Class] == TANK)
return SendClientMessage(playerid, red, "<X> You can't use this command with your class");
aRPG[playerid] += ammo;
ENME(playerid, C_E, "<!> You deposit %d ammo | Now your total of RPG is: %d", ammo, aRPG[playerid]);
eAmmo-=ammo;
SetPlayerWeapon(playerid, 35, eAmmo);
new INI:File = INI_Open(Account(playerid));
INI_SetTag(File, "Weapons");
INI_WriteInt(File, "aRPG", aRPG[playerid]);
INI_Close(File);
}
else
return SendClientMessage(playerid, red, "<X> You don't have the ammo that you want deposit");
return 1;
}
YCMD:pstock(playerid, params[], help)
{
if(EPInfo[playerid][Level] < 1)
return 0;
new ID;
if(sscanf(params, "u", ID))
return SendClientMessage(playerid, red, "<X> Use /pstock <PlayerID/Name>");
if(!IsPlayerConnected(ID))
return SendClientMessage(playerid, red, "<X> Player not found");
if(EPInfo[ID][Log] == 0)
return SendClientMessage(playerid, red, "<X> This player is not registered");
SendClientMessage(playerid, green, Lines);
ENME(playerid, C_E, "RPG: %d", aRPG[ID]);
SendClientMessage(playerid, green, Lines);
return 1;
}
#define ENME(%0,%1,%2,%3) do{new _string[128]; format(_string,sizeof(_string),%2,%3); SendClientMessage(%0,%1,_string);} while(FALSE)
password = 7A3E129EB9D4B09B33BBE71795E807F0C21E7D1178C9375CA5 98C2D67EA6ECC2164F20C8B3DDD094B6C32964B017A67D5326 F698CEBEDE36B9926C3DD341D199
I translated my script, sorry if my english is bad.