SA-MP Forums Archive
Weapons aren't loading correctly. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Weapons aren't loading correctly. (/showthread.php?tid=450130)



Weapons aren't loading correctly. - Isolated - 11.07.2013

Hey there,

When a player spawns in on the server, his weapons are set to the default which is fine, however, when he quits, his stats are updated and it's fine inside the database. The default set to 0 so when his stats are loaded correctly and he spawns, his weapons are then set back to default. Why could this be?

pawn Код:
GivePlayerWeapons(playerid)
{
    if(PlayerInfo[playerid][pGun1] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pGun1Ammo]);
    if(PlayerInfo[playerid][pGun2] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun2], PlayerInfo[playerid][pGun2Ammo]);
    if(PlayerInfo[playerid][pGun3] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun3], PlayerInfo[playerid][pGun3Ammo]);
    if(PlayerInfo[playerid][pGun4] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun4], PlayerInfo[playerid][pGun4Ammo]);
    if(PlayerInfo[playerid][pGun5] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun5], PlayerInfo[playerid][pGun5Ammo]);
    if(PlayerInfo[playerid][pGun6] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun6], PlayerInfo[playerid][pGun6Ammo]);
    if(PlayerInfo[playerid][pGun7] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun7], PlayerInfo[playerid][pGun7Ammo]);
    if(PlayerInfo[playerid][pGun8] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun8], PlayerInfo[playerid][pGun8Ammo]);
    if(PlayerInfo[playerid][pGun9] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun9], PlayerInfo[playerid][pGun9Ammo]);
    if(PlayerInfo[playerid][pGun10] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun10], PlayerInfo[playerid][pGun10Ammo]);
    if(PlayerInfo[playerid][pGun11] != 0)
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun11], PlayerInfo[playerid][pGun11Ammo]);
    else GivePlayerWeapon(playerid, 24, 160); GivePlayerWeapon(playerid, 26, 84); GivePlayerWeapon(playerid, 28, 370);
}

I'm grateful for any form of help.

Thanks.


Re: Weapons aren't loading correctly. - Misiur - 11.07.2013

The else clause is executed only for last p11 gun slot.
I'd suggest changing pGun1, pGun2 to pGun[11], so then you can use

pawn Код:
GivePlayerWeapons(playerid)
{
    new bool:def = true;
    for(new i = 0; i != 11; ++i) {
        if(PlayerInfo[playerid][pGun][i]) {
            GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun][i], PlayerInfo[playerid][pGunAmmo][i]);
            def = false;
        }
    }
    if(def) {
        GivePlayerWeapon(playerid, 24, 160); GivePlayerWeapon(playerid, 26, 84); GivePlayerWeapon(playerid, 28, 370);
    }
}



Re: Weapons aren't loading correctly. - Isolated - 11.07.2013

Doesn't work. Still having the same problem.


Re: Weapons aren't loading correctly. - ToiletDuck - 12.07.2013

Try to put GivePlayerWeapons(playerid) under OnplayerSpawn or OnplayerLogin..
This should work 100percent