Jump to content

Showing 'nil' in Gui...


Mann56

Recommended Posts

Hey Guys,

I was making a resource where i encountered a problem. The problem is whenever i open the gui i made, the label which shows variable VapidCount always shows nil... This is because the gui is triggered before the functioning defining VapidCount, how can i prevent this... as the bindKey wants the gui function executed before itself but i need to make the gui after the showVapidCount function.

window = {} 
label = {} 
function showVapidCount(Vapid) 
if Vapid then 
    if Vapid == nil then 
    VapidCount = 1 
    else 
    VapidCount = Vapid 
    end 
else  
    VapidCount = 0 
end 
end 
addEvent("VapidStock",true) 
addEventHandler("VapidStock",root,showVapidCount) 
  
function createGUI() 
        window.stock = guiCreateWindow(533, 136, 378, 496, "My Window", false) 
        guiWindowSetSizable(window.stock, false) 
        label.lol = guiCreateLabel(8, 28, 360, 37, "Vapid Stock : "..tostring(VapidCount).."", false, window.stock)     
        guiSetVisible(window.stock,false) 
    end 
addEventHandler("onClientResourceStart", resourceRoot, createGUI) 
  
local state = false 
  
bindKey ( "f5", "down", function () 
  
if state == false then 
guiSetVisible(window.stock,true) 
showCursor(true) 
state = true 
else 
  
guiSetVisible(window.stock,false) 
showCursor(false) 
state = false 
end 
end 
) 

Some help/advice would be appreciated.

Regards,

Mann

Link to comment

Show the triggerClientEvent function with "VapidStock".

I think it doesnt even trigger correctly.

Or you can put an outputDebugString ( tostring ( Vapid ) ) in showVapidCount (first line).

Then the debugscript should tell us more.

Link to comment
Show the triggerClientEvent function with "VapidStock".

I think it doesnt even trigger correctly.

Or you can put an outputDebugString ( tostring ( Vapid ) ) in showVapidCount (first line).

Then the debugscript should tell us more.

Yup the function is working correctly.

Client

window = {} 
label = {} 
function showVapidCount(Vapid) 
outputDebugString ( tostring ( Vapid ) ) 
if Vapid then 
    if Vapid == nil then 
    VapidCount = 1 
    else 
    VapidCount = Vapid 
    end 
else  
    VapidCount = 0 
end 
end 
addEvent("VapidStock",true) 
addEventHandler("VapidStock",root,showVapidCount) 
  
function createGUI() 
        window.stock = guiCreateWindow(533, 136, 378, 496, "My Window", false) 
        guiWindowSetSizable(window.stock, false) 
        label.lol = guiCreateLabel(8, 28, 360, 37, "Vapid Stock : "..tostring(VapidCount).."", false, window.stock)     
        guiSetVisible(window.stock,false) 
    end 
addEventHandler("onClientResourceStart", resourceRoot, createGUI) 
  
local state = false 
  
bindKey ( "f5", "down", function () 
  
if state == false then 
guiSetVisible(window.stock,true) 
showCursor(true) 
state = true 
else 
  
guiSetVisible(window.stock,false) 
showCursor(false) 
state = false 
end 
end 
) 

EDIT : The script is working now, i did :

window = {} 
label = {} 
function showVapidCount(Vapid) 
outputDebugString ( tostring ( Vapid ) ) 
if Vapid then 
    if Vapid == nil then 
    VapidCount = 1 
    else 
    VapidCount = Vapid 
    end 
else  
    VapidCount = 0 
end 
end 
addEvent("VapidStock",true) 
addEventHandler("VapidStock",root,showVapidCount) 
  
function createGUI() 
        window.stock = guiCreateWindow(533, 136, 378, 496, "My Window", false) 
        guiWindowSetSizable(window.stock, false) 
        label.lol = guiCreateLabel(8, 28, 360, 37, "Vapid Stock : "..tostring(VapidCount).."", false, window.stock)     
        guiSetVisible(window.stock,true) 
end 
  
local state = false 
  
bindKey ( "f5", "down", function () 
  
if state == false then 
createGUI() 
showCursor(true) 
state = true 
else 
  
guiSetVisible(window.stock,false) 
showCursor(false) 
state = false 
end 
end 
) 

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