Jump to content

weaponsTable


Kenix

Recommended Posts

script does not work :( . debug he wrote in a bad argument # 1 to 'random' (interval is empty). help please I'm trying to do in each slot gated random weapons.

error on line 10

  
g_Root = getRootElement() 
  
local w1Table = { [4]='1', [5]='1', [6]='1', [8]='1', [9]='1' } 
local w2Table = { [25]='50', [26]='50', [27]='200' } 
local w3Table = { [28]='150', [29]='150', [32]='150' } 
local w4Table = { [30]='100', [31]='100'  } 
local w5Table = { [33]='30', [34]='30' } 
  
function givewaeponsplayeronroundstart(thePlayer, weaponID, ammo) 
giveWeapon(w1Table[math.random(#w1Table)]) 
giveWeapon(w2Table[math.random(#w2Table)]) 
giveWeapon(w3Table[math.random(#w3Table)]) 
giveWeapon(w4Table[math.random(#w4Table)]) 
giveWeapon(w5Table[math.random(#w5Table)]) 
end 
addEventHandler ( "onGamemodeMapStart", g_Root, givewaeponsplayeronroundstart ) 
setTimer(givewaeponsplayeronroundstart, 1000, 0) 
  

Link to comment

the function is: math.random(x,y)

where x is the lowest result and y the highest.

ul also need to specify who to give the weapons to since its a server side function.

giveWeapon ( ped thePlayer, int weapon [, int ammo=30, bool setAsCurrent=false ] )

so for you, im guessing you need to give all players these random weapons, so you will need a loop,

try this sorry but i dont have time to try it out.

  
g_Root = getRootElement() 
local w1Table = { 4, 5, 6, 8, 9 } 
local w2Table = { 25, 26, 27 } 
local w3Table = { 28, 27, 32 } 
local w4Table = { 30, 31 } 
local w5Table = { 33, 34 } 
  
function giveWeaponsOnRoundStart() 
    for k,v in ipairs(getElementsByType("player")) do 
        giveWeapon(v, w1Table[math.random(1,#w1Table)],1) 
        giveWeapon(v, w2Table[math.random(1,#w2Table)],100) 
        giveWeapon(v, w3Table[math.random(1,#w3Table)],150) 
        giveWeapon(v, w4Table[math.random(1,#w4Table)],100) 
        giveWeapon(v, w5Table[math.random(1,#w5Table)],30) 
    end 
end 
addEventHandler ( "onGamemodeMapStart", g_Root, giveWeaponsOnRoundStart ) 
  

Link to comment
the function is: math.random(x,y)

where x is the lowest result and y the highest.

ul also need to specify who to give the weapons to since its a server side function.

giveWeapon ( ped thePlayer, int weapon [, int ammo=30, bool setAsCurrent=false ] )

so for you, im guessing you need to give all players these random weapons, so you will need a loop,

try this sorry but i dont have time to try it out.

  
g_Root = getRootElement() 
local w1Table = { 4, 5, 6, 8, 9 } 
local w2Table = { 25, 26, 27 } 
local w3Table = { 28, 27, 32 } 
local w4Table = { 30, 31 } 
local w5Table = { 33, 34 } 
  
function giveWeaponsOnRoundStart() 
    for k,v in ipairs(getElementsByType("player")) do 
        giveWeapon(v, w1Table[math.random(1,#w1Table)],1) 
        giveWeapon(v, w2Table[math.random(1,#w2Table)],100) 
        giveWeapon(v, w3Table[math.random(1,#w3Table)],150) 
        giveWeapon(v, w4Table[math.random(1,#w4Table)],100) 
        giveWeapon(v, w5Table[math.random(1,#w5Table)],30) 
    end 
end 
addEventHandler ( "onGamemodeMapStart", g_Root, giveWeaponsOnRoundStart ) 
  

thanks a lot dude :)

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...