xTravax Posted August 1, 2014 Posted August 1, 2014 (edited) hi this code isnt working function openGui() if guiGetVisible ( GUIEditor_Window[1] ) then -- line 100 guiSetVisible ( GUIEditor_Window[1], false ) showCursor(false) guiSetInputEnabled(false) else guiSetVisible ( GUIEditor_Window[1], true ) -- line 105 showCursor(true) guiSetInputEnabled(true) end end bindKey("F6","down",openGui) line 100: attemp to index global 'GUIEditor_Window' a nil value please help im new to gui Edited August 1, 2014 by Guest
TAPL Posted August 1, 2014 Posted August 1, 2014 Put this on the top of the script. GUIEditor_Window = {}
xTravax Posted August 1, 2014 Author Posted August 1, 2014 i got warnings in line 100 and 105 bad argument guiGetVisible and guiSetVisible (expected gui-element at argument 1,got nil) edit: nvm i fixed it by myself,thanks
xTravax Posted August 1, 2014 Author Posted August 1, 2014 just one more thing why do i keep getting error expected element at argument 2 but got nil? function colt ( ) outputChatBox("Colt-45",localPlayer) end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], colt, false )
TAPL Posted August 1, 2014 Posted August 1, 2014 Add the event after you create the button not before. Also the function outputChatBox client side doesn't require player element.
xTravax Posted August 2, 2014 Author Posted August 2, 2014 it's already under it i have first function which guieditor resource made and my function is already under that function so button is already created but when i click on it it doesnt output anything as it gives that error - expected element at argument 2 but got nil
TAPL Posted August 2, 2014 Posted August 2, 2014 I guess you created the button inside the event onClientResourceStart and added the event onClientGUIClick outside the event onClientResourceStart which mean the button won't get create until the resource started fully and you tried to attach the button to the event onClientGUIClick before the resource started fully so that you get the error.
Anubhav Posted August 2, 2014 Posted August 2, 2014 function colt ( ) outputChatBox("Colt-45") end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], colt, false ) See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
xTravax Posted August 2, 2014 Author Posted August 2, 2014 function colt ( ) outputChatBox("Colt-45") end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], colt, false ) i dont understand how would this fix the problem the problem is it says (for addEventHandler: )element on argument 2 is nil - GUIEditor.button[1] <-- that one and that button is already created in window but it still says that its nil
TAPL Posted August 2, 2014 Posted August 2, 2014 yeah correct but, how do i fix this then? Simply create the button outside the event onClientResourceStart but then you will need also to create the window outside the event because you are attaching the button to the window, Another option would be adding the event onClientGUIClick inside the event onClientResourceStart.
Max+ Posted August 2, 2014 Posted August 2, 2014 -- Like this , GUIEditor_Window = {} addEventHandler ( 'onClientGUIClick', resourceRoot, function ( ) if ( source == GUIEditor.button[1] ) then outputChatBox("Colt-45", 255, 255, 0 ) end end ) ----- bindKey("F6","down", function ( ) if guiGetVisible ( GUIEditor_Window[1] ) == true then guiSetVisible ( GUIEditor_Window[1], false ) showCursor(false) guiSetInputEnabled(false) else guiSetVisible ( GUIEditor_Window[1], true ) showCursor(true) guiSetInputEnabled(true) end end ) - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
Max+ Posted August 2, 2014 Posted August 2, 2014 ok thanks tapl and max You'r welcome - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
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