SA-MP Forums Archive
їPor quй no funciona esto? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: їPor quй no funciona esto? (/showthread.php?tid=417544)



їPor quй no funciona esto? - TiNcH010 - 21.02.2013

їPor quй me funciona una sola vez esta funciуn y luego no?

pawn Код:
stock RemovePlayerWeapon(playerid, weaponid)
{
  new plyWeapons[12];
  new plyAmmo[12];
  for(new slot = 0; slot != 12; slot++)
  {
    new wep, ammo;
    GetPlayerWeaponData(playerid, slot, wep, ammo);
    if(wep != weaponid)
    {
      GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
    }
  }
  ResetPlayerWeapons(playerid);
  for(new slot = 0; slot != 12; slot++)
  {
    GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]);
  }
}
Quiero quitarle el arma que tiene actualmente el jugador pero sуlo funciona una vez (estando en un vehнculo) y para que funcione debo bajarme del vehнculo.


Respuesta: їPor quй no funciona esto? - oOFotherOo - 21.02.2013

Prueba con este:

pawn Код:
stock ResetPlayerWeaponsEx(playerid,...)
{
    new W[] =
    {
        0,0,1,1,1,1,1,1,1,1,10,10,10,10,10,10,8,8,
        8,0,0,0,2,2,2,3,3,3,4,4,5,5,4,6,6,7,7,7,7,
        8,12,9,9,9,11,11,11,11
    };
 
    new
        idx = 0,
        tmp = 0,
        weapons,
        args = numargs() - 1,
        bool:Reset[13] = {true,...};
 
 
    if(IsPlayerConnected(playerid))
    {
        if(args > 0)
        {
            if(args <= 46)
            {
                while(args > idx++)
                {
                    new wep = getarg(idx);
 
                    if(0 <= wep <= 46)
                    {
                        GetPlayerWeaponData(playerid,W[wep],weapons,tmp);
 
                        if(weapons == wep)
                        {
                            Reset[W[wep]] = false;
                        }
                    }
                    else
                    {
                        printf("ResetPlayerWeaponEx warning: invalid argument (argument: #%d)! \"%d\" is not a valid weapon!", idx+1,wep);
                    }
                }
 
                for(new a = 0; a < 13; a ++)
                {
                    if(Reset[a])
                    {
                        GetPlayerWeaponData(playerid,a,weapons,tmp);
 
                        if(weapons)
                        {
                            SetPlayerAmmo(playerid,weapons,0);
 
                            weapons = -1;
                        }
                    }
                    else
                    {
                        Reset[a] = true;
                    }
                }
                return 1;
            }
            print("ResetPlayerWeaponsEx Error: You have specified over 46 weapons! Check for duplicate weapons");
            return 1;
        }
        ResetPlayerWeapons(playerid);
        return 1;
    }
    return 1;
}
Un saludo.