Jump to content

Hi guys.Need help.Tables.


Bzz335

Recommended Posts

Hi guys.I have table with amount.

  
local money={ 
[1]={math.random(150,400)}, 
[2]={math.random(400,600)}, 
[3]={math.random(600,800)}, 
[4]={math.random(800,1000)}, 
[5]={math.random(800,1000)}, 
[6]={math.random(800,1000)}, 
} 
addEventHandler ("onPlayerDamage", getRootElement(),  
function(attacker, weapon, bodypart, loss) 
givePlayerMoney(attacker,!?)-- Here's need value from string in table money [1]. 
end 
  

thanks.

Link to comment
local money = 
{ 
    [ 1 ] = math.random ( 150, 400 ), 
    [ 2 ] = math.random ( 400, 600 ), 
    [ 3 ] = math.random ( 600, 800 ), 
    [ 4 ] = math.random ( 800, 1000 ), 
    [ 5 ] = math.random ( 800, 1000 ), 
    [ 6 ] = math.random ( 800, 1000 ), 
} 
  
addEventHandler ( "onPlayerDamage", getRootElement(), 
    function ( attacker, weapon, bodypart, loss ) 
        givePlayerMoney ( attacker, money [ math.random ( #money ) ] ) 
    end 
) 

That's what you wanted?

Link to comment
local money = 
{ 
    [ 1 ] = math.random ( 150, 400 ), 
    [ 2 ] = math.random ( 400, 600 ), 
    [ 3 ] = math.random ( 600, 800 ), 
    [ 4 ] = math.random ( 800, 1000 ), 
    [ 5 ] = math.random ( 800, 1000 ), 
    [ 6 ] = math.random ( 800, 1000 ), 
} 
  
addEventHandler ( "onPlayerDamage", getRootElement(), 
    function ( attacker, weapon, bodypart, loss ) 
        givePlayerMoney ( attacker, money [ 1 ] ) 
    end 
) 

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