Jump to content

Question


WASSIm.

Recommended Posts

Don't put it in the event?

for example:

local window = guiCreateWindow(...) 
  
addEventHandler("onClientRender",getRootElement(), 
function() 
guiSetVisible(window,false) -- or whatever  
end 
) 

i need windows in onClientRender but if make it its create again

addEventHandler("onClientRender",getRootElement(), 
function() 
window = guiCreateWindow(...) 
end 
) 

Link to comment
addEventHandler( "onClientRnder", root, 
    function( ) 
        if window then 
            return 
        end 
        window = guiCreateWindow( ... ) 
    end 
) 

now windows not working and if make local nothing change

Link to comment
Post whole code!
function main ( ) 
    start = getTickCount() 
    addEventHandler ("onClientRender",  root, move) 
end 
bindKey ("F2","down", main) 
  
function move ( )  
        local x = 0.5 
        local y = 0.5 
        local w = 0.6 
        local h = 0.6 
        local now = getTickCount() 
        local elapsedTime = now - start 
        local endtime = start + 1000 
        local duration = endtime - start 
        local progress = elapsedTime / duration 
        local w1, h1, z = interpolateBetween ( 0, 0, 0, w, h, 0, progress, "OutInBounce") 
        x1 = x-(w1/2) 
        y1 = y-(h1/2) 
        local dxgui = guidxCreateWindow(x1,y1,w1, h1,"SHOP PANEL",70) 
end 

Link to comment

That should be enough:

function main ( ) 
    start = getTickCount() 
    addEventHandler ("onClientRender",  root, move) 
end 
bindKey ("F2","down", main) 
  
function move ( ) 
        if not dxgui then 
        local x = 0.5 
        local y = 0.5 
        local w = 0.6 
        local h = 0.6 
        local now = getTickCount() 
        local elapsedTime = now - start 
        local endtime = start + 1000 
        local duration = endtime - start 
        local progress = elapsedTime / duration 
        local w1, h1, z = interpolateBetween ( 0, 0, 0, w, h, 0, progress, "OutInBounce") 
        x1 = x-(w1/2) 
        y1 = y-(h1/2) 
        local dxgui = guidxCreateWindow(x1,y1,w1, h1,"SHOP PANEL",70) 
        end 
end 

Link to comment
  
function guidxCreateWindow(x,y,w,h,text,alpha)  
    local sx,sy = guiGetScreenSize ( ) 
    local win = guiCreateStaticImage( sx*x,sy*y,sx*w,sy*h, "black.png", false) 
    local wx, wy = guiGetSize ( win, false ) 
    guiSetProperty( win, "Alpha", alpha) 
    local winup = guiCreateStaticImage( 0,0,1,0.1, "winup.jpg", true, win ) 
    local text = guiCreateLabel(0,0,1, 1,text,true, winup) 
    guiSetProperty( text, "Alpha", 300) 
    guiLabelSetHorizontalAlign(text, "center") 
    guiLabelSetVerticalAlign(text, "center") 
    guiSetFont ( text, guiCreateFont( "font.ttf", 30 ) ) 
    return win 
end 
  
  
function main ( ) 
    start = getTickCount() 
    addEventHandler ("onClientRender",  root, pingstate) 
end 
bindKey ("F2","down", main) 
  
function pingstate ( )  
        if not dxgui then 
        local x = 0.5 
        local y = 0.5 
        local w = 0.6 
        local h = 0.6 
         
        local now = getTickCount() 
        local elapsedTime = now - start 
        local endtime = start + 1000 
        local duration = endtime - start 
        local progress = elapsedTime / duration 
        local w1, h1, z = interpolateBetween ( 0, 0, 0, w, h, 0, progress, "OutInBounce") 
         
        x1 = x-(w1/2) 
        y1 = y-(h1/2) 
        local dxgui = guidxCreateWindow(x1,y1,w1, h1,"SHOP PANEL",70) 
        end 
end 
  

Link to comment

Thanks :D

its working in first time and now i changed something and now not moving and panel working

function guidxCreateWindow(x,y,w,h,text)  
    win = guiCreateStaticImage( x,y,w,h, "black.png", false) 
    local wx, wy = guiGetSize ( win, false ) 
    guiSetProperty( win, "Alpha", 70) 
    local winup = guiCreateStaticImage( 0,0,1,0.1, "winup.jpg", true, win ) 
    local text = guiCreateLabel(0,0,1, 1,text,true, winup) 
    guiSetProperty( text, "Alpha", 300) 
    guiLabelSetHorizontalAlign(text, "center") 
    guiLabelSetVerticalAlign(text, "center") 
    guiSetFont ( text, guiCreateFont( "font.ttf", 30 ) ) 
    return win 
end 
  
     
function main ( )  
    if ( guiGetVisible ( win ) == true ) then 
        start = getTickCount() 
        addEventHandler ("onClientRender",  root, move) 
    else             
        removeEventHandler ("onClientRender",  root, move) 
    end 
end 
addEventHandler ("onClientResourceStart",  root, main) 
  
function move ( )  
    local x, y = guiGetPosition ( win, false ) 
    local w, h = guiGetSize ( win, false ) 
    local now = getTickCount() 
    local elapsedTime = now - start 
    local endtime = start + 1000 
    local duration = endtime - start 
    local progress = elapsedTime / duration 
    local w1, h1, z = interpolateBetween ( 0, 0, 0, w, h, 0, progress, "Linear") 
    local x1 = x-(w1/2) 
    local y1 = y-(h1/2) 
    guiSetPosition ( win, x1, y1, false) 
    guiSetSize ( win, w1, h1, false) 
end 
  
--------------------------------------------------TEST------------------------------------------- 
local sx,sy = guiGetScreenSize ( ) 
local dxgui = guidxCreateWindow( sx*0.5, sy*0.5, sx*0.6, sy*0.6,"TEST PANEL") 
guiSetVisible ( dxgui, false ) 
  
function test ( )  
    if ( guiGetVisible ( dxgui ) == false ) then 
        guiSetVisible ( dxgui, true ) 
    else             
        guiSetVisible ( dxgui, false ) 
    end 
end 
bindKey ("F2","down", test) 
  

Link to comment
function guidxCreateWindow(x,y,w,h,text) 
    local win = guiCreateStaticImage( x,y,w,h, "black.png", false) 
    local wx, wy = guiGetSize ( win, false ) 
    guiSetProperty( win, "Alpha", 70) 
    local winup = guiCreateStaticImage( 0,0,1,0.1, "winup.jpg", true, win ) 
    local text = guiCreateLabel(0,0,1, 1,text,true, winup) 
    guiSetProperty( text, "Alpha", 300) 
    guiLabelSetHorizontalAlign(text, "center") 
    guiLabelSetVerticalAlign(text, "center") 
    guiSetFont ( text, guiCreateFont( "font.ttf", 30 ) ) 
    return win 
end 
  
--------------------------------------------------TEST------------------------------------------- 
local sx,sy = guiGetScreenSize ( ) 
local dxgui = guidxCreateWindow( sx*0.5, sy*0.5, sx*0.6, sy*0.6,"TEST PANEL") 
guiSetVisible ( dxgui, false ) 
  
function move ( ) 
    local x, y = guiGetPosition ( dxgui, false ) 
    local w, h = guiGetSize ( dxgui, false ) 
    local now = getTickCount() 
    local elapsedTime = now - start 
    local endtime = start + 1000 
    local duration = endtime - start 
    local progress = elapsedTime / duration 
    local w1, h1, z = interpolateBetween ( 0, 0, 0, w, h, 0, progress, "Linear") 
    local x1 = x-(w1/2) 
    local y1 = y-(h1/2) 
    guiSetPosition ( dxgui, x1, y1, false) 
    guiSetSize ( dxgui, w1, h1, false) 
end 
  
function test ( ) 
    if ( guiGetVisible ( dxgui ) == false ) then 
        guiSetVisible ( dxgui, true ) 
        start = getTickCount() 
        addEventHandler ("onClientRender",  root, move) 
    else             
        guiSetVisible ( dxgui, false ) 
        removeEventHandler ("onClientRender",  root, move) 
    end 
end 
bindKey ("F2","down", test) 

Link to comment

no no no i dont want that

i make this because i want all ( guidxCreateWindow ) moving

function main ( ) 
    if ( guiGetVisible ( win ) == true ) then 
        start = getTickCount() 
        addEventHandler ("onClientRender",  root, move) 
    else             
        removeEventHandler ("onClientRender",  root, move) 
    end 
end 
addEventHandler ("onClientResourceStart",  root, main) 

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