Jump to content

motd script need help.


Miika

Recommended Posts

Hi!

My motd script doesn't work.

ERROR: Loading script failed: info-window\client.lua:7: ') expected (to close '(' at line 6) near '=' 
 

[Client]

function drawText() 
    local sWidth,sHeight = guiGetScreenSize() 
    dxDrawRectangle(sWidth*0.1427525622254758,sHeight*0.9557291666666667,sWidth*0.6991215226939971,sHeight*0.04296875,tocolor(0,0,0,150),false) 
    dxDrawText(Texto,sWidth*0.328696925329429,sHeight*0.9661458333333333,sWidth*0.664714494875549,sHeight*0.9895833333333333,tocolor(0,255,0,255),0.6,"bankgothic","center","top",false,false,false) 
     
    setTimer( 
        Texto = "Muista pitää hauskaa!" 
        if Texto == "Muista pitää hauskaa!" then 
        Texto = "Donaamalla Miikalle 10e psc, saat modet." 
        elseif Texto == "Donaamalla Miikalle 10e psc, saat modet." then 
        Texto = "Lisää infoa Miikalta." 
        elseif Texto == "Lisää infoa Miikalta." then 
        Texto = "Kutsu toki kaverisikin pelaamaan!" 
        elseif Texto == "Kutsu toki kaverisikin pelaamaan!" then 
        Texto = "Älähän kinua rankkia :3" 
        elseif Texto == "Älähän kinua rankkia :3" then 
        Texto = "Muista pitää hauskaa!" 
        end, 
    10000, 0) 
end 
  
function doText(command, ...) 
    if command == "motdon" then 
        text = table.concat({...}," ") 
        addEventHandler("onClientRender", getRootElement(), drawText) 
    elseif command == "motdoff" then 
        removeEventHandler("onClientRender", getRootElement(), drawText)    -- this time we use removeEventHandler 
    end 
end 
addCommandHandler("motdon", doText) 
addCommandHandler("motdoff", doText) 
  

What is the problem?

Link to comment

You added a timer inside an onClientRender event with the wrong syntax. This is a valid way to define a timer:

setTimer(function()  
    -- Code here 
end, 10000, 1) 

Move it outside the render event to hide the text after ~10 seconds (if that's what you're trying to do), as you do now it will attempt to hide the text 600'000 times after 10 seconds during 10 seconds, that's not a good idea.

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