SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 24/04/2011, 10:16 PM   #1
borba
Little Clucker
 
Join Date: Apr 2011
Posts: 14
Reputation: 0
Default [UNSOLVED] Crashing after loading weapons.

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.

Last edited by borba; 25/04/2011 at 06:01 PM.
borba is offline  
Old 24/04/2011, 10:39 PM   #2
Tee
Gangsta
 
Join Date: Sep 2010
Posts: 836
Reputation: 81
Default Re: Crashing after loading weapons.

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.
__________________
1.3 inch/360 - pretty high for precision
Tee is offline  
Old 24/04/2011, 10:43 PM   #3
borba
Little Clucker
 
Join Date: Apr 2011
Posts: 14
Reputation: 0
Default Re: Crashing after loading weapons.

dini_Int retrives an int from a term in a file, isn't it? As I can see, I'm loading. o_O
borba is offline  
Old 24/04/2011, 10:46 PM   #4
Tee
Gangsta
 
Join Date: Sep 2010
Posts: 836
Reputation: 81
Default Re: Crashing after loading weapons.

Yes it does but if you did not save WeaponSlot0 and Weapon0Ammo you cannot load it. o_O!
__________________
1.3 inch/360 - pretty high for precision
Tee is offline  
Old 24/04/2011, 10:52 PM   #5
borba
Little Clucker
 
Join Date: Apr 2011
Posts: 14
Reputation: 0
Default Re: Crashing after loading weapons.

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).
borba is offline  
Old 24/04/2011, 10:58 PM   #6
Tee
Gangsta
 
Join Date: Sep 2010
Posts: 836
Reputation: 81
Default Re: Crashing after loading weapons.

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?
__________________
1.3 inch/360 - pretty high for precision
Tee is offline  
Old 24/04/2011, 11:09 PM   #7
borba
Little Clucker
 
Join Date: Apr 2011
Posts: 14
Reputation: 0
Default Re: Crashing after loading weapons.

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?!

Last edited by borba; 24/04/2011 at 11:49 PM.
borba is offline  
Old 25/04/2011, 05:11 PM   #8
borba
Little Clucker
 
Join Date: Apr 2011
Posts: 14
Reputation: 0
Default Re: Crashing after loading weapons.

bump, I really need this.
borba is offline  
Old 27/04/2011, 08:45 AM   #9
Kasis
Huge Clucker
 
Kasis's Avatar
 
Join Date: Mar 2010
Location: Weed, New Mexico
Posts: 413
Reputation: 81
Default Re: Crashing after loading weapons.

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.
__________________
Kasis is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making weapons loading short ||123|| Help Archive 5 04/09/2010 07:03 PM
SA Crashing before loading screen 1990_LX Client Support 13 14/07/2010 07:18 AM
-1 Ammo bug when loading players weapons. Johndaone Help Archive 2 15/06/2010 05:35 AM
Crashing at loading with sa-mp-0.3-RC9-1. T0bb3 Help Archive 1 13/10/2009 03:15 PM
I keep crashing after the loading screen Soto Client Support 2 15/04/2009 03:08 PM


All times are GMT. The time now is 06:47 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.