Jump to content

GUI help


mint3d

Recommended Posts

So i want this to close after a time of 1 min cant get it to work so here it is

function drawStuff() 
    dxDrawRectangle ( x/3.8, y/3.8, x/2.02, y/2, tocolor ( 0, 0, 0, 150 ) )  
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) . 
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.48, y/3.58, x, y, tocolor ( 0, 0, 0, 255 ), 1, "bankgothic" )  
end 
  
addEventHandler("onClientRender", root, drawStuff)  
  
  

Link to comment
function drawStuff() 
    dxDrawRectangle ( x/3.8, y/3.8, x/2.02, y/2, tocolor ( 0, 0, 0, 150 ) )  
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" )  
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.48, y/3.58, x, y, tocolor ( 0, 0, 0, 255 ), 1, "bankgothic" ) 
end 
  
function closedrawstuff () 
    guiSetVisible (drawstuff, false) 
end 
  
local seconds = 50 
setTimer ( closedrawstuff, ( seconds * 100 ), 1 ) 
  

Thats not right is it?

Link to comment

You want to set the drawstuff gui invisible, but you have no gui. Solidsnake gave you a function ( removeEventHandler ) and use it like this:

function drawStuff() 
    dxDrawRectangle ( x/3.8, y/3.8, x/2.02, y/2, tocolor ( 0, 0, 0, 150 ) ) 
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) 
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.48, y/3.58, x, y, tocolor ( 0, 0, 0, 255 ), 1, "bankgothic" ) 
end 
  
addEventHandler('onClientRender', getRootElement(), drawStuff) 
  
local seconds = 50 
  
setTimer ( function() removeEventHandler("onClientRender", getRootElement(), drawStuff) end, ( seconds * 100 ), 1 ) 

OR

function drawStuff() 
    dxDrawRectangle ( x/3.8, y/3.8, x/2.02, y/2, tocolor ( 0, 0, 0, 150 ) ) 
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) 
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.48, y/3.58, x, y, tocolor ( 0, 0, 0, 255 ), 1, "bankgothic" ) 
end 
  
addEventHandler('onClientRender', getRootElement(), drawStuff) 
  
function closedrawstuff() 
    removeEventHandler("onClientRender", getRootElement(), drawStuff)  
end 
     
local seconds = 50 
     
setTimer ( closedrawstuff, ( seconds * 100 ), 1 ) 

They're the same thing, but the second one is easier

Edited by Guest
Link to comment
local playerName = getPlayerName(getLocalPlayer()) 

For x and y actually you can just sub in the numbers like so:

dxDrawRectangle ( x/3.8, y/3.8, x/2.02, y/2, tocolor ( 0, 0, 0, 150 ) )  --You had it like this 
  
dxDrawRectangle ( posX, posY, sizeX, sizeY, tocolor ( 0, 0, 0, 150 ) ) -- You need it like this 

Same for the dxDrawText's

Link to comment
local x,y = guiGetScreenSize()  
local playerName = getPlayerName ( localPlayer )   
  
  
function drawStuff() 
    dxDrawRectangle ( x/3.8, y/3.8, x/2.02, y/2, tocolor ( 0, 0, 0, 150 ) ) 
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) 
    dxDrawText ( "Welcome to\nLos Santos Roleplay " .. playerName, x/3.48, y/3.58, x, y, tocolor ( 0, 0, 0, 255 ), 1, "bankgothic" ) 
end 
  
addEventHandler('onClientRender', getRootElement(), drawStuff) 
  
function closedrawstuff() 
    removeEventHandler("onClientRender", getRootElement(), drawStuff) 
end 
    
local seconds = 50 
    
setTimer ( closedrawstuff, ( seconds * 100 ), 1 ) 

I took it my own way and this works thanks for the help tho

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