LGato Posted May 4, 2019 Share Posted May 4, 2019 I want know what fail in my script because i'm new in LUA Scripting and if a "professional" resolve my problem maybe i can learn of that In this script i want make math problems and if the players resolve this gain $2k setTimer(function() x1 = math.random(500) x2 = math.random(600) outputChatBox("#1860F1[Math]#ffffff " .. x1 .. " + " .. x2 .. " = ", root, 255, 255, 255, true) end, 30000, 0) function mathSystem(text, source) outputChatBox(text, source, 255, 255, 255, true) if text == x1 + x2 then givePlayerMoney(source, 2000) end end addEventHandler("onPlayerChat", root, mathSystem) Link to comment
x1Father,_) Posted May 5, 2019 Share Posted May 5, 2019 setTimer(function() x1 = math.random(1,1000) x2 = math.random(1,1000) outputChatBox("#1860F1[Math]#ffffff " .. x1 .. " + " .. x2 .. " = ", root, 255, 255, 255, true) end, 30000, 0) function mathSystem(text, source) outputChatBox(text, source, 255, 255, 255, true) if text == x1 + x2 then givePlayerMoney(source, 2000) end end addEventHandler("onPlayerChat", root, mathSystem) Quote That's the error math.random need to be for example (1,500) from 1 to 500 Link to comment
Hakan Posted May 5, 2019 Share Posted May 5, 2019 try this local result = nil setTimer(function() local x1,x2 = math.random(1,1000) , math.random(1,1000) result = x1 + x2 outputChatBox("#1860F1[Math]#ffffff " .. x1 .. " + " .. x2 .. " = ", root, 255, 255, 255, true) end, 30000, 0) addEventHandler ( "onPlayerChat" , root , function ( message , typ ) if ( typ == 0 and result ~= nil and message == tostring ( result ) ) then givePlayerMoney ( source , 2000 ) result = nil end end ) Link to comment
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