SetPlayerWeapons(playerid);
#1

This is a small part of the callback I use to give the saved guns back after the player been on /adminduty
pawn Код:
public SetPlayerWeapons(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pJailed] < 1)
        {
            if(Spectate[playerid] == 255)
            {
                if (PlayerInfo[playerid][pWeapon] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon], PlayerInfo[playerid][pAmmo]);
                    //PlayerInfo[playerid][pWeapon] = 0; PlayerInfo[playerid][pAmmo] = 0;
                }
                if (PlayerInfo[playerid][pWeapon2] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon2], PlayerInfo[playerid][pAmmo2]);
                    //PlayerInfo[playerid][pWeapon2] = 0; PlayerInfo[playerid][pAmmo2] = 0;
                }
                if (PlayerInfo[playerid][pWeapon3] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon3], PlayerInfo[playerid][pAmmo3]);
                    //PlayerInfo[playerid][pWeapon3] = 0; PlayerInfo[playerid][pAmmo3] = 0;
                }
When I have the commented lines as a comment I get the weapons I had before going on admin duty but I also gets more ammo each time I go off admin duty and will allways spawn with those weapons. Un-comment the lines I don't get any weapon that I had before going on admin duty.
So.. How can I make it so I will get the weapons I had before going on admin duty but it wont increase the ammo each time I go off aduty?
Reply
#2

Can't you just use ResetPlayerWeapons before giving the player the weapons?
Reply
#3

GivePlayerWeapon ultimately "adds" to the players ammo.

Simply do what BenzoAMG stated.
Reply
#4

Exactly, thank you Blake.

(Make sure you're not resetting the player's weapons after you've given a weapon, place the function before you give any weapons)
Reply
#5

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Exactly, thank you Blake.

(Make sure you're not resetting the player's weapons after you've given a weapon, place the function before you give any weapons)
You're welcome Threshold.
Reply
#6

It only gives me the weapon I got latest.
Reply
#7

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Exactly, thank you Blake.

(Make sure you're not resetting the player's weapons after you've given a weapon, place the function before you give any weapons)
Oh.. That was exactly what I did lol.. So never mind it works now! Thanks!
Reply
#8

I noticed now that it still add on ammo. This is my code
pawn Код:
public SetPlayerWeapons(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pJailed] < 1)
        {
            if(Spectate[playerid] == 255)
            {
                SafeResetPlayerWeapons(playerid);
                if (PlayerInfo[playerid][pWeapon] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon], PlayerInfo[playerid][pAmmo]);
                }
                if (PlayerInfo[playerid][pWeapon2] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon2], PlayerInfo[playerid][pAmmo2]);
                }
                if (PlayerInfo[playerid][pWeapon3] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon3], PlayerInfo[playerid][pAmmo3]);
                }
                if (PlayerInfo[playerid][pWeapon4] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon4], PlayerInfo[playerid][pAmmo4]);
                }
                if (PlayerInfo[playerid][pWeapon5] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon5], PlayerInfo[playerid][pAmmo5]);
                }
                if (PlayerInfo[playerid][pWeapon6] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon6], PlayerInfo[playerid][pAmmo6]);
                }
                if (PlayerInfo[playerid][pWeapon7] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon7], PlayerInfo[playerid][pAmmo7]);
                }
                if (PlayerInfo[playerid][pWeapon8] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon8], PlayerInfo[playerid][pAmmo8]);
                }
                if (PlayerInfo[playerid][pWeapon9] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon9], PlayerInfo[playerid][pAmmo9]);
                }
                if (PlayerInfo[playerid][pWeapon10] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon10], PlayerInfo[playerid][pAmmo10]);
                }
                if (PlayerInfo[playerid][pWeapon11] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon11], PlayerInfo[playerid][pAmmo11]);
                }
                if (PlayerInfo[playerid][pWeapon12] > 0)
                {
                    SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon12], PlayerInfo[playerid][pAmmo12]);
                }
            }
            else
            {
                if(PlayerInfo[playerid][pAdminDuty] == 1 && PlayerInfo[playerid][pAdmin] >= 6)
                {
                    for (new i=0; i<13; i++)
                    {
                        SafeResetPlayerWeapons(playerid);
                        SafeGivePlayerWeapon(playerid, OtherWeapons[playerid][i],OtherAmmo[playerid][i]);
                    }
                }
                else
                {
                    SafeResetPlayerWeapons(playerid);
                    if (PlayerInfo[playerid][pWeapon] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon], PlayerInfo[playerid][pAmmo]);
                    }
                    if (PlayerInfo[playerid][pWeapon2] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon2], PlayerInfo[playerid][pAmmo2]);
                    }
                    if (PlayerInfo[playerid][pWeapon3] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon3], PlayerInfo[playerid][pAmmo3]);
                    }
                    if (PlayerInfo[playerid][pWeapon4] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon4], PlayerInfo[playerid][pAmmo4]);
                    }
                    if (PlayerInfo[playerid][pWeapon5] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon5], PlayerInfo[playerid][pAmmo5]);
                    }
                    if (PlayerInfo[playerid][pWeapon6] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon6], PlayerInfo[playerid][pAmmo6]);
                    }
                    if (PlayerInfo[playerid][pWeapon7] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon7], PlayerInfo[playerid][pAmmo7]);
                    }
                    if (PlayerInfo[playerid][pWeapon8] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon8], PlayerInfo[playerid][pAmmo8]);
                    }
                    if (PlayerInfo[playerid][pWeapon9] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon9], PlayerInfo[playerid][pAmmo9]);
                    }
                    if (PlayerInfo[playerid][pWeapon10] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon10], PlayerInfo[playerid][pAmmo10]);
                    }
                    if (PlayerInfo[playerid][pWeapon11] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon11], PlayerInfo[playerid][pAmmo11]);
                    }
                    if (PlayerInfo[playerid][pWeapon12] > 0)
                    {
                        SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon12], PlayerInfo[playerid][pAmmo12]);
                    }
                }
            }
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)