Bzz335 Posted January 11, 2014 Posted January 11, 2014 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.
Castillo Posted January 11, 2014 Posted January 11, 2014 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?
Bzz335 Posted January 11, 2014 Author Posted January 11, 2014 No. See.for 1 situation he must get math.random(150,400)[1] in another math.random(400,600)[2]. But thanks,Castillo.
Castillo Posted January 11, 2014 Posted January 11, 2014 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 )
TAPL Posted January 11, 2014 Posted January 11, 2014 The table will not be updated, you should move the table inside the function.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now