Jump to content

Doesn't output message


proracer

Recommended Posts

-- Easy maths 
mathTableEasy = {} 
    mathTableEasy[1] = "2 + 2 = ?" 
    mathTableEasy[2] = "5 * 5 = ?" 
    mathTableEasy[3] = "8 / 2 = ?" 
    mathTableEasy[4] = "10 - 5 = ?" 
    mathTableEasy[5] = "19 + 10 = ?" 
    mathTableEasy[6] = "24 * 5 = ?" 
    mathTableEasy[7] = "120 / 5 = ?" 
    mathTableEasy[8] = "127 - 69 = ?" 
    mathTableEasy[9] = "11 * 11 = ?" 
    mathTableEasy[10] = "108 / 9 = ?" 
     
-- Mediocre maths 
mathTableMedium = {} 
    mathTableMedium[1] = "39 + 28 = ?" 
    mathTableMedium[2] = "43 - 52 = ?" 
    mathTableMedium[3] = "29 * 6 = ?" 
    mathTableMedium[4] = "240 / 15 = ?" 
    mathTableMedium[5] = "Pi = ?" 
    mathTableMedium[6] = "2 ^ 8 = ?" 
    mathTableMedium[7] = "3 ^ 4 = ?" 
    mathTableMedium[8] = "582 - 334 = ?" 
    mathTableMedium[9] = "392 + 382 = ?" 
    mathTableMedium[10] = "125 * 3  = ?" 
     
-- Hard maths 
mathTableHard = {} 
    mathTableHard[1] = "3921 + 192 = ?" 
    mathTableHard[2]  ="2912 - 585 = ?" 
    mathTableHard[3] = "273 * 4 = ?" 
    mathTableHard[4] = "384 / 4 = ?" 
    mathTableHard[5] = "Square root of 625 = ?" 
    mathTableHard[6] = "Square root of 121 = ?" 
    mathTableHard[7] = "Square root of 196 = ?" 
    mathTableHard[8] = "Square root of 289 = ?" 
    mathTableHard[9] = "100 ^ 3 = ?" 
    mathTableHard[10] = "19295 + (-123 * 4) = ?" 
  
function mathQuestions(message, messageType) 
    outputChatBox(tostring(mathTableEasy[1]), getRootElement(), 0, 91, 255) 
        if messageType == 0 and message == "4" then 
        outputChatBox("Correct!") 
            else 
            outputChatBox("Incorrect!") 
        end 
end 
addEventHandler("onPlayerChat", getRootElement(), mathQuestions) 

It won't output message to the chatbox. :cry:

Link to comment

Sorry, I wanted to express the other way around.

It should be vice-versa.First it should output message ' 2 + 2 = ? ' and if you type '4' it should say 'Correct!'

EDIT: I have fixed it. :P

-- Easy maths 
mathTableEasy = {} 
    mathTableEasy[1] = "2 + 2 = ?" 
    mathTableEasy[2] = "5 * 5 = ?" 
    mathTableEasy[3] = "8 / 2 = ?" 
    mathTableEasy[4] = "10 - 5 = ?" 
    mathTableEasy[5] = "19 + 10 = ?" 
    mathTableEasy[6] = "24 * 5 = ?" 
    mathTableEasy[7] = "120 / 5 = ?" 
    mathTableEasy[8] = "127 - 69 = ?" 
    mathTableEasy[9] = "11 * 11 = ?" 
    mathTableEasy[10] = "108 / 9 = ?" 
     
-- Mediocre maths 
mathTableMedium = {} 
    mathTableMedium[1] = "39 + 28 = ?" 
    mathTableMedium[2] = "43 - 52 = ?" 
    mathTableMedium[3] = "29 * 6 = ?" 
    mathTableMedium[4] = "240 / 15 = ?" 
    mathTableMedium[5] = "Pi = ?" 
    mathTableMedium[6] = "2 ^ 8 = ?" 
    mathTableMedium[7] = "3 ^ 4 = ?" 
    mathTableMedium[8] = "582 - 334 = ?" 
    mathTableMedium[9] = "392 + 382 = ?" 
    mathTableMedium[10] = "125 * 3  = ?" 
     
-- Hard maths 
mathTableHard = {} 
    mathTableHard[1] = "3921 + 192 = ?" 
    mathTableHard[2]  ="2912 - 585 = ?" 
    mathTableHard[3] = "273 * 4 = ?" 
    mathTableHard[4] = "384 / 4 = ?" 
    mathTableHard[5] = "Square root of 625 = ?" 
    mathTableHard[6] = "Square root of 121 = ?" 
    mathTableHard[7] = "Square root of 196 = ?" 
    mathTableHard[8] = "Square root of 289 = ?" 
    mathTableHard[9] = "100 ^ 3 = ?" 
    mathTableHard[10] = "19295 + (-123 * 4) = ?" 
  
function mathQuestion() 
    outputChatBox(tostring(mathTableEasy[1]), getRootElement(), 0, 91, 255) 
end 
  
function mathAnswer(message, messageType) 
        if messageType == 0 and message == "4" then 
        outputChatBox("Correct!") 
            else 
            outputChatBox("Incorrect!") 
        end 
end 
addEventHandler("onPlayerChat", getRootElement(), mathAnswer) 
addEventHandler("onResourceStart", getRootElement(), mathQuestion) 

P.S. Really stupid :lol:

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