RemovePlayerWeapon, i cant scroll through weapons after i used this function
#1

hey all,

i was busy with my trunk system, when i found this small bugg, and i dont really understand what's wrong in this stock...

pawn Код:
stock RemovePlayerWeapon(playerid, pweaponid)
{
        new plyWeapons[12];
        new plyAmmo[12];
 
        for(new slot = 0; slot != 12; slot++)
        {
                new pwep, pammo;
                GetPlayerWeaponData(playerid, slot, pwep, pammo);
 
                if(pwep != pweaponid)
                {
                        GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
                }
        }
 
        ResetPlayerWeapons(playerid);
        for(new slot = 0; slot != 12; slot++)
        {
                GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]);
        }
}
when i do for example RemovePlayerWeapon(playerid, 22); then it DOES remove the weapon from the player, but when i want to scroll through the weapons, it doesnt works... it keeps going back to the fist...

anybody knows what is wrong with this code?

greets
Reply
#2

pawn Код:
forward DropPlayerWeapon(playerid,weaponid);
public DropPlayerWeapon(playerid,weaponid)
{
    if(!IsPlayerConnected(playerid) || weaponid == 0) return 0;
    new wp,ammo,weap[13][2];
    for (new i=0; i<13; i++)
    {
        GetPlayerWeaponData(playerid,i,wp,ammo);
        if(ammo <= -1 && i >= 2)
        {
            wp = 0;
            ammo = 0;
        }
        if(wp != weaponid)
        {
            weap[i][0] = wp;
            weap[i][1] = ammo;
        }
    }
    ResetPlayerWeapons(playerid);
    for(new i=0;i<13;i++)
    {
        new wid = weap[i][0];
        new wam = weap[i][1];
        if(wid != 0 && wam >0)
        {
            GivePlayerWeapon(playerid,wid,wam);
        }
    }
    return 1;
}
this is my function and works fine, use it
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
Are you sure it is that code that is the problem, not how you call it?
yes i am sure, since i found out that it was something with the ammo that was given to the player.... so i set it to 9999, when giving back the weapons to the player, though it aint the best fix.

Quote:
Originally Posted by mineralo
Посмотреть сообщение
pawn Код:
forward DropPlayerWeapon(playerid,weaponid);
public DropPlayerWeapon(playerid,weaponid)
{
    if(!IsPlayerConnected(playerid) || weaponid == 0) return 0;
    new wp,ammo,weap[13][2];
    for (new i=0; i<13; i++)
    {
        GetPlayerWeaponData(playerid,i,wp,ammo);
        if(ammo <= -1 && i >= 2)
        {
            wp = 0;
            ammo = 0;
        }
        if(wp != weaponid)
        {
            weap[i][0] = wp;
            weap[i][1] = ammo;
        }
    }
    ResetPlayerWeapons(playerid);
    for(new i=0;i<13;i++)
    {
        new wid = weap[i][0];
        new wam = weap[i][1];
        if(wid != 0 && wam >0)
        {
            GivePlayerWeapon(playerid,wid,wam);
        }
    }
    return 1;
}
this is my function and works fine, use it
thanks , ill use that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)