[UNSOLVED] Crashing after loading weapons. -
borba - 24.04.2011
Sup guys!
After the player logs in the server, it loads his weapons:
Code:
AccountInfo[playerid][WeaponSlot0] = dini_Int(arquivo, "SlotArma0"); AccountInfo[playerid][WeaponSlot0Ammo] = dini_Int(arquivo, "MunicaoSlotArma0");
AccountInfo[playerid][WeaponSlot1] = dini_Int(arquivo, "SlotArma1"); AccountInfo[playerid][WeaponSlot1Ammo] = dini_Int(arquivo, "MunicaoSlotArma1");
AccountInfo[playerid][WeaponSlot2] = dini_Int(arquivo, "SlotArma2"); AccountInfo[playerid][WeaponSlot2Ammo] = dini_Int(arquivo, "MunicaoSlotArma2");
AccountInfo[playerid][WeaponSlot3] = dini_Int(arquivo, "SlotArma3"); AccountInfo[playerid][WeaponSlot3Ammo] = dini_Int(arquivo, "MunicaoSlotArma3");
AccountInfo[playerid][WeaponSlot4] = dini_Int(arquivo, "SlotArma4"); AccountInfo[playerid][WeaponSlot4Ammo] = dini_Int(arquivo, "MunicaoSlotArma4");
AccountInfo[playerid][WeaponSlot5] = dini_Int(arquivo, "SlotArma5"); AccountInfo[playerid][WeaponSlot5Ammo] = dini_Int(arquivo, "MunicaoSlotArma5");
AccountInfo[playerid][WeaponSlot6] = dini_Int(arquivo, "SlotArma6"); AccountInfo[playerid][WeaponSlot6Ammo] = dini_Int(arquivo, "MunicaoSlotArma6");
AccountInfo[playerid][WeaponSlot7] = dini_Int(arquivo, "SlotArma7"); AccountInfo[playerid][WeaponSlot7Ammo] = dini_Int(arquivo, "MunicaoSlotArma7");
AccountInfo[playerid][WeaponSlot8] = dini_Int(arquivo, "SlotArma8"); AccountInfo[playerid][WeaponSlot8Ammo] = dini_Int(arquivo, "MunicaoSlotArma8");
AccountInfo[playerid][WeaponSlot9] = dini_Int(arquivo, "SlotArma9"); AccountInfo[playerid][WeaponSlot9Ammo] = dini_Int(arquivo, "MunicaoSlotArma9");
AccountInfo[playerid][WeaponSlot10] = dini_Int(arquivo, "SlotArma10"); AccountInfo[playerid][WeaponSlot10Ammo] = dini_Int(arquivo, "MunicaoSlotArma10");
AccountInfo[playerid][WeaponSlot11] = dini_Int(arquivo, "SlotArma11"); AccountInfo[playerid][WeaponSlot11Ammo] = dini_Int(arquivo, "MunicaoSlotArma11");
AccountInfo[playerid][WeaponSlot12] = dini_Int(arquivo, "SlotArma12"); AccountInfo[playerid][WeaponSlot12Ammo] = dini_Int(arquivo, "MunicaoSlotArma12");
SetPVarInt(playerid, "RecentlyLogged", 1);
and as you can see in the end, I create a PVAR to check that the player has recently logged in, so when he spawns I can do this:
Code:
if(GetPVarInt(playerid, "RecentlyLogged") == 1)
{
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot0], AccountInfo[playerid][WeaponSlot0Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot1], AccountInfo[playerid][WeaponSlot1Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot2], AccountInfo[playerid][WeaponSlot2Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot3], AccountInfo[playerid][WeaponSlot3Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot4], AccountInfo[playerid][WeaponSlot4Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot5], AccountInfo[playerid][WeaponSlot5Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot6], AccountInfo[playerid][WeaponSlot6Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot7], AccountInfo[playerid][WeaponSlot7Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot8], AccountInfo[playerid][WeaponSlot8Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot9], AccountInfo[playerid][WeaponSlot9Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot10], AccountInfo[playerid][WeaponSlot10Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot11], AccountInfo[playerid][WeaponSlot11Ammo]);
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot12], AccountInfo[playerid][WeaponSlot12Ammo]);
DeletePVar(playerid, "RecentlyLogged");
}
But the player is crashing, I can see it loading the wepons, but then GTA closes.
Re: Crashing after loading weapons. -
Tee - 24.04.2011
As i can see in the 1st code. You are not loading WeaponSlot0 and WeaponSlot0Ammo. So you should not do this:
pawn Code:
GivePlayerWeapon(playerid, AccountInfo[playerid][WeaponSlot0], AccountInfo[playerid][WeaponSlot0Ammo]);
Take that out and try.
Re: Crashing after loading weapons. -
borba - 24.04.2011
dini_Int retrives an int from a term in a file, isn't it? As I can see, I'm loading. o_O
Re: Crashing after loading weapons. -
Tee - 24.04.2011
Yes it does but if you did not save WeaponSlot0 and Weapon0Ammo you cannot load it. o_O!
Re: Crashing after loading weapons. -
borba - 24.04.2011
In the .ini file, the player has his weapons saved. When I remove the wepon loading code (when the player spawns) everything becomes normal (it just doesn't load the weapons, yet, with I got a new weapon and exit, it saves).
Re: Crashing after loading weapons. -
Tee - 24.04.2011
Sorry my, I did not see that you saved, WeaponSlot0 and WeaponSlot0Ammo. When does the normal stats load (Like cash, score, adminlevel, etc)? Does it load on spawn or on Connect?
Re: Crashing after loading weapons. -
borba - 24.04.2011
On Spawn, I'm using a PVAR to set that the player recently logged in and I check if that is true OnPlayerSpawn
It's loaded when the player's password is typed correctly in the dialog.
EDIT: I noticed that when loading player stats, it is returning always 0.
Code:
AccountInfo[playerid][WeaponSlot2] = dini_Int(arquivo, "SlotArma2");
AccountInfo[playerid][WeaponSlot2Ammo] = dini_Int(arquivo, "MunicaoSlotArma2");
(this happens in all others weapons when loading them)
But, there in the player file, "SlotArma2" is 24 and "MunicaoSlotArma2" is 300.
What's happening?!
Re: Crashing after loading weapons. -
borba - 25.04.2011
bump, I really need this.
Re: Crashing after loading weapons. -
Kasis - 27.04.2011
Dude, i have same problem and i can't figure out how to fix it. If i will get solution i will tell you. Only thing, i don't crash but the weapons simply doesn't load.