Jump to content

Ter todas as armas


Recommended Posts

Eai pessoal, blz?

Antigamente eu tinha visto um mod que permitia ter todas as armas (voce podia ter por exemplo pistola e depois trocava para silenciador e depois para desert eagle, parecendo que voce pode ter todas as armas) queria saber como fazer isso(ter as armas e ficar trocando elas normalmente como se não existisse a restrinção de uma arma por slot).

Obrigado!

Link to comment

Bom tentei fazer um pouco mas não consigo passar dessa parte, alguem pode me ajudar?

-- same weapon slot 
local playersWeapons = {} 
--[[ 
playersWeapons[p] = { 
currentSelectedSlot = 0, 
currentSelectedIndex = 0, 
weapons = { 
[0] = { 
Brass Knuckles = false 
}, 
[1] = { 
weaponId = 4-- knife 
}, 
[2] = { 
[22] = {ammo = 0}, --pistol 
[23] = {ammo = 0}, --Silenced pistol 
[24] = {ammo = 0} --Desert eagle 
}, 
[3] = { 
[25] = {ammo = 0}, --Shotgun 
[26] = {ammo = 0}, --Sawnoff 
[27] = {ammo = 0} --Spaz 
}, 
[4] = { 
[28] = {ammo = 0}, --Uzi 
[29] = {ammo = 0}, --Mp5 
[32] = {ammo = 0} --Tec9 
}, 
[5] = { 
[30] = {ammo = 0}, --Ak47 
[31] = {ammo = 0} --M4 
}, 
[6] = { 
[33] = {ammo = 0}, --Rifle 
[34] = {ammo = 0} --Sniper 
}, 
[7] = { 
[35] = {ammo = 0}, --Rocket launcher 
[36] = {ammo = 0}, --Bazooka 
[37] = {ammo = 0}, --FlameTrol 
[38] = {ammo = 0} --Minigun 
}, 
[8] = { 
[16] = {ammo = 0}, --Grenade 
[17] = {ammo = 0}, --Tear gas 
[18] = {ammo = 0}, --Molotov 
[39] = {ammo = 0} --Satchel 
}, 
[9] = { 
[41] = {ammo = 0}, --Spray 
[42] = {ammo = 0}, --FireExtinter 
[43] = {ammo = 0} --Camera 
}, 
[10] = { 
--nil 
}, 
[11] = { 
[44] = {ammo = 0}, --Night vision 
[45] = {ammo = 0}, --Infrared 
[46] = {ammo = 0} --Parachute 
}, 
[12] = { 
[40] = {ammo = 0} -- satchel detonator 
} 
} 
  
} 
  
]] 
  
function onPlayerConnect() 
playersWeapons[source] = { 
currentSelectedSlot = 0, 
currentSelectedIndex = 0, 
weapons = { 
[0] = { 
Brass Knuckles = false 
}, 
[1] = { 
weaponId = 4-- knife 
}, 
[2] = { 
[22] = {ammo = 0}, --pistol 
[23] = {ammo = 0}, --Silenced pistol 
[24] = {ammo = 0} --Desert eagle 
}, 
[3] = { 
[25] = {ammo = 0}, --Shotgun 
[26] = {ammo = 0}, --Sawnoff 
[27] = {ammo = 0} --Spaz 
}, 
[4] = { 
[28] = {ammo = 0}, --Uzi 
[29] = {ammo = 0}, --Mp5 
[32] = {ammo = 0} --Tec9 
}, 
[5] = { 
[30] = {ammo = 0}, --Ak47 
[31] = {ammo = 0} --M4 
}, 
[6] = { 
[33] = {ammo = 0}, --Rifle 
[34] = {ammo = 0} --Sniper 
}, 
[7] = { 
[35] = {ammo = 0}, --Rocket launcher 
[36] = {ammo = 0}, --Bazooka 
[37] = {ammo = 0}, --FlameTrol 
[38] = {ammo = 0} --Minigun 
}, 
[8] = { 
[16] = {ammo = 0}, --Grenade 
[17] = {ammo = 0}, --Tear gas 
[18] = {ammo = 0}, --Molotov 
[39] = {ammo = 0} --Satchel 
}, 
[9] = { 
[41] = {ammo = 0}, --Spray 
[42] = {ammo = 0}, --FireExtinter 
[43] = {ammo = 0} --Camera 
}, 
[10] = { 
--nil 
}, 
[11] = { 
[44] = {ammo = 0}, --Night vision 
[45] = {ammo = 0}, --Infrared 
[46] = {ammo = 0} --Parachute 
}, 
[12] = { 
[40] = {ammo = 0} -- satchel detonator 
} 
} 
  
} 
  
end 
addEventHandler("onPlayerConnect",root,onPlayerConnect) 
  
function onPlayerWeaponSwitch(previousWeaponID,currentWeaponID) 
--cancelEvent() 
local ammo = getPedTotalAmmo(source) 
if(previousWeaponID>currentWeaponID) 
onPrevious(source,previousWeaponID,currentWeaponID,ammo) 
else 
onNext(source,previousWeaponID,currentWeaponID,ammo) 
end 
end 
addEventHandler("onPlayerWeaponSwitch",root,onPlayerWeaponSwitch) 
-- onClientPlayerWeaponSwitch 
  
function onNext(player,oldWeaponID,currentWeaponID,ammo) 
SaveOldWeaponID(source,oldWeaponID,ammo) 
end 
  
function onPrevious(player,oldWeaponID,currentWeaponID,ammo) 
SaveOldWeaponID(source,oldWeaponID,ammo) 
end 
  
function SaveOldWeaponID(player,id,ammoN) 
local oldWeaponSlot = getSlotFromWeapon(id) 
playersWeapons[player][weapons][oldWeaponSlot][id][ammo] = ammoN 
takeWeapon(player,id) 
end 
  
function nextSlot(player) 
playersWeapons[player].currentSelectedSlot = playersWeapons[player].currentSelectedSlot+1 
if(playersWeapons[player].currentSelectedSlot>12)then 
playersWeapons[player].currentSelectedSlot = 0 
end 
  
setPedWeaponSlot(player,playersWeapons[player].currentSelectedSlot) 
  
end 
  
function previousSlot(player) 
playersWeapons[player].currentSelectedSlot = playersWeapons[player].currentSelectedSlot-1 
if(playersWeapons[player].currentSelectedSlot<0)then 
playersWeapons[player].currentSelectedSlot = 0 
end 
  
setPedWeaponSlot(player,playersWeapons[player].currentSelectedSlot) 
end 
  

Link to comment
Bom tentei fazer um pouco mas não consigo passar dessa parte, alguem pode me ajudar?
-- 

Algo assim deve funcionar:

Weapons = { 
    [0] = { 0, 1 },                         --  Punho 
    [1] = { 2, 3, 4, 5, 6, 7, 8, 9 },       --  Melee 
    [2] = { 22, 23, 24 },                   --  Pistolas 
    [3] = { 25, 26, 27 },                   --  Shotguns 
    [4] = { 28, 29, 32 },                   --  SMGs 
    [5] = { 30, 31 },                       --  Fuzis 
    [6] = { 33, 34 },                       --  Rifles 
    [7] = { 35, 36, 37, 38 },               --  Pesadas 
    [8] = { 16, 17, 18, 39 },               --  Projeteis 
    [9] = { 41, 42, 43 },                   --  Especiais 1 
    [10] = { 10, 11, 12, 14, 15 },          --  Dildos etc 
    [11] = { 44, 45, 46 },                  --  Oculos e paraquedas 
    [12] = { 40 }                           --  Detonador 
} 
  
function scrollUp ( thePlayer ) 
    local slot = getSlotFromWeapon ( getPedWeapon ( thePlayer ) ); 
    local pos  = getWeaponPositionInSlot ( getPedWeapon ( thePlayer ), slot ); 
    local id 
     
    if ( pos == 1 ) then 
        local p_slot = slot == 0 and #Weapons or slot -1 
        id = Weapons[p_slot][#Weapons[p_slot]]; 
    else 
        id = Weapons[slot][pos -1]; 
    end 
    giveWeapon ( thePlayer, id, 999, true ); 
end  
  
function scrollDown ( thePlayer ) 
    local slot = getSlotFromWeapon ( getPedWeapon ( thePlayer ) ); 
    local pos  = getWeaponPositionInSlot ( getPedWeapon ( thePlayer ), slot ); 
    local id 
     
    if ( pos == #Weapons[slot] ) then 
        local n_slot = slot == #Weapons and 0 or slot +1 
        id = Weapons[n_slot][1]; 
    else 
        id = Weapons[slot][pos +1]; 
    end 
    giveWeapon ( thePlayer, id, 999, true ); 
end  
  
--------------------------------------------¬ Util 
  
function getWeaponPositionInSlot ( id, slot ) 
    for i, v in ipairs ( Weapons[slot] ) do 
        if ( v == id ) then 
            return i 
        end 
    end 
    return false 
end 
  
--------------------------------------------¬ Bind 
  
addEventHandler ( "onResourceStart", resourceRoot, 
function() 
    for _,v in ipairs ( getElementsByType ( "player" ) ) do 
        bindKey ( v, "mouse_wheel_down", "down", scrollDown ); 
        bindKey ( v, "mouse_wheel_up", "down", scrollUp ); 
         
        bindKey ( v, "e", "down", scrollDown ); 
        bindKey ( v, "q", "down", scrollUp ); 
    end 
end ) 
  
addEventHandler ( "onPlayerJoin", root, 
function ( ) 
    bindKey ( source, "mouse_wheel_down", "down", scrollDown ); 
    bindKey ( source, "mouse_wheel_up", "down", scrollUp ); 
     
    bindKey ( source, "e", "down", scrollDown ); 
    bindKey ( source, "q", "down", scrollUp ); 
end ) 

Tente entender o código, qualquer duvida poste aqui :P

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...