Jump to content

Image appears two times


BriGhtx3

Recommended Posts

client

  
function StrafHandler ( gesch, money ) 
  
GUIEditor_Label = {} 
  
img = guiCreateStaticImage(392,0,407,268,"Blitzer.png",false) 
guiSetAlpha(img,0.89999997615814) 
  
GUIEditor_Label[1] = guiCreateLabel(592,97,195,35,"Bahnhof",false) 
guiLabelSetColor(GUIEditor_Label[1],0,0,0) 
guiSetFont(GUIEditor_Label[1],"sa-header") 
setTimer(ausblenden, 3000, 1) 
  end 
addEvent( "onStrafe", true ) 
addEventHandler( "onStrafe", getRootElement(), StrafHandler ) 
  
function ausblenden() 
  
        guiSetVisible(img, false) 
  
end 
  

server

  
local within = isElementWithinColShape( hitElement, circle) 
        if within then 
            local money = vioGetElementData(hitElement, "money") 
            speedx, speedy, speedz = getElementVelocity (hitElement) 
            actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) 
             
            kmh = actualspeed * 180 
  
            geld = kmh/100*200 
            if kmh > 80 then 
                triggerClientEvent(hitElement,"onStrafe", getRootElement(), kmh, geld) 
            end 
        end 

When I drive through the sphere the image appears. After 3 seconds it hides.

When I drive through it a second time then it appears twice and doesn't hide.

Link to comment

You should check if the image already exists, if so, show it, else create it.

function StrafHandler ( gesch, money ) 
if not img then 
GUIEditor_Label = {} 
img = guiCreateStaticImage(392,0,407,268,"Blitzer.png",false) 
guiSetAlpha(img,0.89999997615814) 
GUIEditor_Label[1] = guiCreateLabel(592,97,195,35,"Bahnhof",false) 
guiLabelSetColor(GUIEditor_Label[1],0,0,0) 
guiSetFont(GUIEditor_Label[1],"sa-header") 
setTimer(ausblenden, 3000, 1) 
else 
guiSetVisible(img, true) 
    end 
end 
addEvent( "onStrafe", true ) 
addEventHandler( "onStrafe", getRootElement(), StrafHandler ) 
  
function ausblenden() 
    if not img then return end 
    guiSetVisible(img, false) 
end 

Test it.

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