Mann56 Posted February 2, 2016 Share Posted February 2, 2016 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
SpecT Posted February 2, 2016 Share Posted February 2, 2016 Define the variable VapidCount so it won't give you nil until the defining function set it. window = {} label = {} local VapidCount = 0 Link to comment
Bonus Posted February 2, 2016 Share Posted February 2, 2016 Or put a simple tostring ( VapidCount or "wait ..." ) in Link to comment
Mann56 Posted February 3, 2016 Author Share Posted February 3, 2016 Define the variable VapidCount so it won't give you nil until the defining function set it. window = {} label = {} local VapidCount = 0 I already tried it but then the gui shows 0 only... Link to comment
Bonus Posted February 3, 2016 Share Posted February 3, 2016 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
Mann56 Posted February 3, 2016 Author Share Posted February 3, 2016 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now