SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 03/05/2014, 05:14 AM   #1
Affan
Huge Clucker
 
Affan's Avatar
 
Join Date: Dec 2012
Posts: 390
Reputation: 28
Default Weapons not loading when relog

pawn Code:
forward LoadWeap_data(playerid,name[],value[]);
public LoadWeap_data(playerid,name[],value[])
{
    INI_Int( "weaponSlot0", weapons[playerid][0][0]);
    INI_Int( "weaponSlot0Ammo", weapons[playerid][0][1]);
    INI_Int( "weaponSlot1", weapons[playerid][1][0]);
    INI_Int( "weaponSlot1Ammo", weapons[playerid][1][1]);
    INI_Int( "weaponSlot2", weapons[playerid][2][0]);
    INI_Int( "weaponSlot2Ammo", weapons[playerid][2][1]);
    INI_Int( "weaponSlot3", weapons[playerid][3][0]);
    INI_Int( "weaponSlot3Ammo", weapons[playerid][3][1]);
    INI_Int( "weaponSlot4", weapons[playerid][4][0]);
    INI_Int( "weaponSlot4Ammo", weapons[playerid][4][1]);
    INI_Int( "weaponSlot5", weapons[playerid][5][0]);
    INI_Int( "weaponSlot5Ammo", weapons[playerid][5][1]);
    INI_Int( "weaponSlot6", weapons[playerid][6][0]);
    INI_Int( "weaponSlot6Ammo", weapons[playerid][6][1]);
    INI_Int( "weaponSlot7", weapons[playerid][7][0]);
    INI_Int( "weaponSlot7Ammo", weapons[playerid][7][1]);
    INI_Int( "weaponSlot8", weapons[playerid][8][0]);
    INI_Int( "weaponSlot8Ammo", weapons[playerid][8][1]);
    INI_Int( "weaponSlot9", weapons[playerid][9][0]);
    INI_Int( "weaponSlot8Ammo", weapons[playerid][9][1]);
    INI_Int( "weaponSlot10", weapons[playerid][10][0]);
    INI_Int( "weaponSlot10Ammo", weapons[playerid][10][1]);
    INI_Int( "weaponSlot11", weapons[playerid][11][0]);
    INI_Int( "weaponSlot11Ammo", weapons[playerid][11][1]);
    INI_Int( "weaponSlot12", weapons[playerid][12][0]);
    INI_Int( "weaponSlot12Ammo", weapons[playerid][12][1]);
    return 1;
}

pawn Code:
forward SaveWeap(playerid);
public SaveWeap(playerid)
{
    new INI:File = INI_Open(wPath(playerid));
    for (new i = 0; i < 13; i++) GetPlayerWeaponData(playerid, i, weapons[playerid][i][0], weapons[playerid][i][1]);
    INI_SetTag(File,"Weapon Data");
    INI_WriteInt(File, "weaponSlot0", weapons[playerid][0][0]);
    INI_WriteInt(File, "weaponSlot0Ammo", weapons[playerid][0][1]);
    INI_WriteInt(File, "weaponSlot1", weapons[playerid][1][0]);
    INI_WriteInt(File, "weaponSlot1Ammo", weapons[playerid][1][1]);
    INI_WriteInt(File, "weaponSlot2", weapons[playerid][2][0]);
    INI_WriteInt(File, "weaponSlot2Ammo", weapons[playerid][2][1]);
    INI_WriteInt(File, "weaponSlot3", weapons[playerid][3][0]);
    INI_WriteInt(File, "weaponSlot3Ammo", weapons[playerid][3][1]);
    INI_WriteInt(File, "weaponSlot4", weapons[playerid][4][0]);
    INI_WriteInt(File, "weaponSlot4Ammo", weapons[playerid][4][1]);
    INI_WriteInt(File, "weaponSlot5", weapons[playerid][5][0]);
    INI_WriteInt(File, "weaponSlot5Ammo", weapons[playerid][5][1]);
    INI_WriteInt(File, "weaponSlot6", weapons[playerid][6][0]);
    INI_WriteInt(File, "weaponSlot6Ammo", weapons[playerid][6][1]);
    INI_WriteInt(File, "weaponSlot7", weapons[playerid][7][0]);
    INI_WriteInt(File, "weaponSlot7Ammo", weapons[playerid][7][1]);
    INI_WriteInt(File, "weaponSlot8", weapons[playerid][8][0]);
    INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][8][1]);
    INI_WriteInt(File, "weaponSlot9", weapons[playerid][9][0]);
    INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][9][1]);
    INI_WriteInt(File, "weaponSlot10", weapons[playerid][10][0]);
    INI_WriteInt(File, "weaponSlot10Ammo", weapons[playerid][10][1]);
    INI_WriteInt(File, "weaponSlot11", weapons[playerid][11][0]);
    INI_WriteInt(File, "weaponSlot11Ammo", weapons[playerid][11][1]);
    INI_WriteInt(File, "weaponSlot12", weapons[playerid][12][0]);
    INI_WriteInt(File, "weaponSlot12Ammo", weapons[playerid][12][1]);
    INI_Close(File);
}

pawn Code:
public OnPlayerSpawn(playerid)
{
    INI_ParseFile(wPath(playerid),"LoadWeap_%s", .bExtra = true, .extra = playerid);
    for (new i = 0; i < 13; i++)
    {
        GetPlayerWeaponData(playerid, i, weapons[playerid][i][0], weapons[playerid][i][1]);
        GivePlayerWeapon(playerid, weapons[playerid][i][0], weapons[playerid][i][1]);
    }
    return 1;
}

pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    SavePlayer(playerid);
    SaveWeap(playerid);
    return 1;
}


The weapons are not loading when you do /q and join back. But it loads when you /kill or die. Any help?
Affan is offline   Reply With Quote
Old 03/05/2014, 05:48 AM   #2
Inn0cent
Huge Clucker
 
Inn0cent's Avatar
 
Join Date: May 2013
Location: Pakistan
Posts: 353
Reputation: 45
Default Re: Weapons not loading when relog

Change This thing "LoadWeap_data" to "LoadWeap" then try.
Inn0cent is offline   Reply With Quote
Old 03/05/2014, 07:12 AM   #3
Affan
Huge Clucker
 
Affan's Avatar
 
Join Date: Dec 2012
Posts: 390
Reputation: 28
Default Re: Weapons not loading when relog

Quote:
Originally Posted by Inn0cent View Post
Change This thing "LoadWeap_data" to "LoadWeap" then try.
It doesn't work.
Affan is offline   Reply With Quote
Old 03/05/2014, 07:17 AM   #4
Inn0cent
Huge Clucker
 
Inn0cent's Avatar
 
Join Date: May 2013
Location: Pakistan
Posts: 353
Reputation: 45
Default Re: Weapons not loading when relog

Maybe, you did not opened the weapons file
Inn0cent is offline   Reply With Quote
Old 03/05/2014, 08:09 AM   #5
EpicMan
Banned
 
Join Date: May 2014
Location: PAKISTAN
Posts: 35
Reputation: 7
Default Re: Weapons not loading when relog

do u have the wepons file .ini
EpicMan is offline   Reply With Quote
Old 03/05/2014, 08:10 AM   #6
Inn0cent
Huge Clucker
 
Inn0cent's Avatar
 
Join Date: May 2013
Location: Pakistan
Posts: 353
Reputation: 45
Default Re: Weapons not loading when relog

Yes he have
Inn0cent is offline   Reply With Quote
Old 03/05/2014, 08:48 AM   #7
Inn0cent
Huge Clucker
 
Inn0cent's Avatar
 
Join Date: May 2013
Location: Pakistan
Posts: 353
Reputation: 45
Default Re: Weapons not loading when relog

You have to add "GivePlayerWeapon" after loading it.
Inn0cent is offline   Reply With Quote
Old 03/05/2014, 09:06 AM   #8
Affan
Huge Clucker
 
Affan's Avatar
 
Join Date: Dec 2012
Posts: 390
Reputation: 28
Default Re: Weapons not loading when relog

Quote:
Originally Posted by Inn0cent View Post
Maybe, you did not opened the weapons file
Thanks for helping via Skype, + Rep'd.
Affan is offline   Reply With Quote
Old 03/05/2014, 05:43 PM   #9
Inn0cent
Huge Clucker
 
Inn0cent's Avatar
 
Join Date: May 2013
Location: Pakistan
Posts: 353
Reputation: 45
Default Re: Weapons not loading when relog

Quote:
Originally Posted by Affan View Post
Thanks for helping via Skype, + Rep'd.
No Problem
Inn0cent is offline   Reply With Quote
Reply

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
This won't work, loading weapons. Dokins Scripting Help 0 06/04/2014 03:18 PM
[Help] Saving + Loading weapons BornHuman Scripting Help 0 28/10/2013 09:25 PM
Weapons MySQL loading ancezas Scripting Help 7 20/03/2013 04:51 PM
Weapons don't save on disconnect/relog Luke_James Scripting Help 4 22/09/2012 10:08 AM
Loading players weapons Snowman12 Scripting Help 1 09/01/2012 12:21 AM


All times are GMT. The time now is 08:33 PM.


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