Best-Killer1 Posted September 11, 2015 Share Posted September 11, 2015 i want add timer for Question (auto ask) and Add the message in bar post to me the code pls i'm learing scripting pls <3 this is the Cood timeToAnswer = 30 -- 30 seconds addCommandHandler ( "math", function ( player ) if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( player ) ), aclGetGroup ( "Level 5" ) ) ) then reward = math.random ( 2000, 5000 ) qn1 = math.random ( 10, 100 ) qn2 = math.random ( 10, 100 ) qn3 = math.random ( 10, 100 ) theQuestion = qn1 + qn2 - qn3 answerTime = setTimer ( noAnswer, timeToAnswer * 1000, 1 ) outputChatBox ( "Math: First one to answer " .. qn1 .. " + " .. qn2 .. " - " .. qn3 .. " will win $" .. reward, root, 0, 255, 0 ) else outputChatBox ( "You can't use this command", player, 255, 0, 0 ) end end ) function noAnswer ( ) outputChatBox ( "Math: Nobody won the answer was " .. theQuestion, root, 0, 255, 0 ) theQuestion = nil end addEventHandler ( "onPlayerChat", root, function ( answer ) if ( theQuestion and tonumber ( answer ) == theQuestion ) then theQuestion = nil outputChatBox ( "Math: " .. getPlayerName ( source ) .. " #00FF00answered " .. answer .. " and won $" .. reward, root, 0, 255, 0, true ) givePlayerMoney ( source, reward ) if ( isTimer ( answerTime ) ) then killTimer ( answerTime ) end end end ) Link to comment
JR10 Posted September 11, 2015 Share Posted September 11, 2015 You can use setTimer to call the function several times. Link to comment
Best-Killer1 Posted September 11, 2015 Author Share Posted September 11, 2015 You can use setTimer to call the function several times. Can explain to me how ? Link to comment
JR10 Posted September 11, 2015 Share Posted September 11, 2015 setTimer(function() reward = math.random ( 2000, 5000 ) qn1 = math.random ( 10, 100 ) qn2 = math.random ( 10, 100 ) qn3 = math.random ( 10, 100 ) theQuestion = qn1 + qn2 - qn3 answerTime = setTimer ( noAnswer, timeToAnswer * 1000, 1 ) outputChatBox ( "Math: First one to answer " .. qn1 .. " + " .. qn2 .. " - " .. qn3 .. " will win $" .. reward, root, 0, 255, 0 ) end, 120000, 0) -- call the function each 2 minutes Link to comment
Best-Killer1 Posted September 11, 2015 Author Share Posted September 11, 2015 setTimer(function() reward = math.random ( 2000, 5000 ) qn1 = math.random ( 10, 100 ) qn2 = math.random ( 10, 100 ) qn3 = math.random ( 10, 100 ) theQuestion = qn1 + qn2 - qn3 answerTime = setTimer ( noAnswer, timeToAnswer * 1000, 1 ) outputChatBox ( "Math: First one to answer " .. qn1 .. " + " .. qn2 .. " - " .. qn3 .. " will win $" .. reward, root, 0, 255, 0 ) end, 120000, 0) -- call the function each 2 minutes Not Work pff bro i get the script from : https://community.multitheftauto.com/in ... ls&id=6126 Try To make it when you have time and send to me it pls <3 really i need it urgent Link to comment
KariiiM Posted September 11, 2015 Share Posted September 11, 2015 Not Work pff bro i get the script from : https://community.multitheftauto.com/in ... ls&id=6126 Try To make it when you have time and send to me it pls <3 really i need it urgent Lmao,What JR10 wrote for you isn't wrong, you can't wait 2 minutes untill the message output? do you know how to read the codes or just copying / posting? Here's the full code edit the timer with your mili seconds setTimer(function() reward = math.random ( 2000, 5000 ) qn1 = math.random ( 10, 100 ) qn2 = math.random ( 10, 100 ) qn3 = math.random ( 10, 100 ) theQuestion = qn1 + qn2 - qn3 answerTime = setTimer ( noAnswer, 30* 1000, 1 ) outputChatBox ( "Math: First one to answer " .. qn1 .. " + " .. qn2 .. " - " .. qn3 .. " will win $" .. reward, root, 0, 255, 0 ) end, 1000, 0) -- it's 1000 mili seconds, mean each 1second it will output a message , edite it with your choice. function noAnswer ( ) outputChatBox ( "Math: Nobody won the answer was " .. theQuestion, root, 0, 255, 0 ) theQuestion = nil end addEventHandler ( "onPlayerChat", root, function ( answer ) if ( theQuestion and tonumber ( answer ) == theQuestion ) then theQuestion = nil outputChatBox ( "Math: " .. getPlayerName ( source ) .. " #00FF00answered " .. answer .. " and won $" .. reward, root, 0, 255, 0, true ) givePlayerMoney ( source, reward ) if ( isTimer ( answerTime ) ) then killTimer ( answerTime ) end end end ) Link to comment
Best-Killer1 Posted September 11, 2015 Author Share Posted September 11, 2015 Not Work pff bro i get the script from : https://community.multitheftauto.com/in ... ls&id=6126 Try To make it when you have time and send to me it pls <3 really i need it urgent Lmao,What JR10 wrote for you isn't wrong, you can't wait 2 minutes untill the message output? do you know how to read the codes or just copying / posting? Here's the full code edit the timer with your mili seconds setTimer(function() reward = math.random ( 2000, 5000 ) qn1 = math.random ( 10, 100 ) qn2 = math.random ( 10, 100 ) qn3 = math.random ( 10, 100 ) theQuestion = qn1 + qn2 - qn3 answerTime = setTimer ( noAnswer, 30* 1000, 1 ) outputChatBox ( "Math: First one to answer " .. qn1 .. " + " .. qn2 .. " - " .. qn3 .. " will win $" .. reward, root, 0, 255, 0 ) end, 1000, 0) -- it's 1000 mili seconds, mean each 1second it will output a message , edite it with your choice. function noAnswer ( ) outputChatBox ( "Math: Nobody won the answer was " .. theQuestion, root, 0, 255, 0 ) theQuestion = nil end addEventHandler ( "onPlayerChat", root, function ( answer ) if ( theQuestion and tonumber ( answer ) == theQuestion ) then theQuestion = nil outputChatBox ( "Math: " .. getPlayerName ( source ) .. " #00FF00answered " .. answer .. " and won $" .. reward, root, 0, 255, 0, true ) givePlayerMoney ( source, reward ) if ( isTimer ( answerTime ) ) then killTimer ( answerTime ) end end end ) See -.- : Loading script failed: SAEGPlayerFunctions\server\math.lua:13: ')' expected (to close '(' at line 2) near 'function' pfff Link to comment
Best-Killer1 Posted September 11, 2015 Author Share Posted September 11, 2015 Fixed Fixed <3 thanx all <3 Link to comment
KariiiM Posted September 11, 2015 Share Posted September 11, 2015 Fixed Fixed <3 thanx all <3 Glad to hear that next time be carefull ! Link to comment
Best-Killer1 Posted September 11, 2015 Author Share Posted September 11, 2015 Other thing guys pls How I can Show The Messages in Bar pls Link to comment
KariiiM Posted September 11, 2015 Share Posted September 11, 2015 Other thing guys pls How I can Show The Messages in Bar pls You have to script your own topbar system or search for it in the community,then exports it to the math script. Link to comment
Best-Killer1 Posted September 11, 2015 Author Share Posted September 11, 2015 Other thing guys pls How I can Show The Messages in Bar pls You have to script your own topbar system or search for it in the community,then exports it to the math script. I Have My Own TopBar But idk How To exports it ahaha (Karim + JR10 Helpful me Thanx Guys <3 ) Link to comment
KariiiM Posted September 11, 2015 Share Posted September 11, 2015 Other thing guys pls How I can Show The Messages in Bar pls You have to script your own topbar system or search for it in the community,then exports it to the math script. I Have My Own TopBar But idk How To exports it ahaha (Karim + JR10 Helpful me Thanx Guys <3 ) Okay then, go to meta.xml of this topbar resource and add the function name who send or put the message. something like that: function="functionname" type="client"/> function="functionname" type="server"/> add the function name to the meta of your topbar resource and be sure your function is in client / server sides after defining the functions in the meta, the question would be ,how to exports the function to other resources? you have two ways to do that exports.resourcename:functionname ("your text",root,200,0,0) or exports['resourcename']:functionname("your text",root,200,0,0) You can also use this way for exporting the functions,by calling the resourcename but it's not usable like these two ways and they do the same job ,it stay your personal choice. call ( getResourceFromName ( "resourcename" ), "functionname", "You were selected!", root, 200,0,0) ~Have fun scripting Regards, KariM Link to comment
Best-Killer1 Posted September 11, 2015 Author Share Posted September 11, 2015 Already Doné But Thanx Bro 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