proracer Posted January 1, 2011 Share Posted January 1, 2011 Hi guys.I have been trying to script a little bit, starting off with creating Rules Window using simple GUI Editor. I came up with this codes. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} showCursor(true,true) GUIEditor_Window[1] = guiCreateWindow(458,280,559,661,"",false) guiSetAlpha(GUIEditor_Window[1],0) GUIEditor_Memo[1] = guiCreateMemo(420,-15181,77,1080,"",false,GUIEditor_Window[1]) guiSetAlpha(GUIEditor_Memo[1],1) guiWindowSetMovable( GUIEditor_Window[1], false ) guiWindowSetSizable( GUIEditor_Window[1], false ) SHC_Testing_Server_Rules = guiCreateWindow(444,238,681,671,"SHC Testing Server Rules 0.1 v",false) Player_Rules_Label = guiCreateLabel(109,87,157,58,"Player Rules",false,SHC_Testing_Server_Rules) guiLabelSetColor(Player_Rules_Label,0,255,0) guiLabelSetVerticalAlign(Player_Rules_Label,"top") guiLabelSetHorizontalAlign(Player_Rules_Label,"left",false) guiSetFont(Player_Rules_Label,"default-bold-small") Player_Rules_Memo = guiCreateMemo(25,105,315,401,"1. Be nice to admins and don't interrupt their work.\n\n2. Do not swear or spam because that will result in a KICK.If you do it several times it will result in a BAN!\n\n3. Do not CHEAT / HACK or use any other 3rd party software because that will result in a INSTANT BAN!\n\n4. If you are experienced in scripting you can freely ask our admins and maybe they let you work.\n\n5. Have fun!",false,SHC_Testing_Server_Rules) Member_Rules_Memo = guiCreateMemo(357,108,315,397,"1. Be nice to players and respect them.\n\n2. In this server you can test your new Resources/Scripts.\n\n3.If some player is asking for help in scripting you can help him but its your choice.\n\n4. As a Member you also must respect Player Rules.\n\n\n5. Have fun!",false,SHC_Testing_Server_Rules) Member_Rules_Label = guiCreateLabel(442,88,105,64,"Member Rules",false,SHC_Testing_Server_Rules) guiLabelSetColor(Member_Rules_Label,0,0,255) guiLabelSetVerticalAlign(Member_Rules_Label,"top") guiLabelSetHorizontalAlign(Member_Rules_Label,"left",false) guiSetFont(Member_Rules_Label,"default-bold-small") GUIEditor_Label[1] = guiCreateLabel(165,38,369,22,"This is a newly created server so this will be constantly updated!",false,SHC_Testing_Server_Rules) guiLabelSetColor(GUIEditor_Label[1],255,0,0) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) MTA_Image = guiCreateStaticImage(264,529,163,106,"images/mtalogo.png",false,SHC_Testing_Server_Rules) I_accept_rules_Button = guiCreateButton(16,556,238,69,"I accept rules!",false,SHC_Testing_Server_Rules) GUIEditor_Button[1] = guiCreateButton(430,554,242,71,"I dont accept rules!",false,SHC_Testing_Server_Rules) end ) addEventHandler("onClientGUIClick", I_accept_rules_Button, acceptRules, false) function acceptRules(button,state) if button == "left" and state == "up" then guiSetVisible( GUIEditor_Window[1], false) showCursor(false,false) outputChatBox("Thank you for accepting our rules.Have fun!") end end The GUI window shows up but when I press accept rules it does really nothing! Please if you can help me I'm a newb. Link to comment
Scooby Posted January 1, 2011 Share Posted January 1, 2011 the addEventHandler for each button should be inside the function. Link to comment
proracer Posted January 1, 2011 Author Share Posted January 1, 2011 Sorry for interupting.Thank you for helping, this is what it came. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} showCursor(true,true) GUIEditor_Window[1] = guiCreateWindow(458,280,559,661,"",false) guiSetAlpha(GUIEditor_Window[1],0) GUIEditor_Memo[1] = guiCreateMemo(420,-15181,77,1080,"",false,GUIEditor_Window[1]) guiSetAlpha(GUIEditor_Memo[1],1) guiWindowSetMovable( GUIEditor_Window[1], false ) guiWindowSetSizable( GUIEditor_Window[1], false ) SHC_Testing_Server_Rules = guiCreateWindow(444,238,681,671,"SHC Testing Server Rules 0.1 v",false) Player_Rules_Label = guiCreateLabel(109,87,157,58,"Player Rules",false,SHC_Testing_Server_Rules) guiLabelSetColor(Player_Rules_Label,0,255,0) guiLabelSetVerticalAlign(Player_Rules_Label,"top") guiLabelSetHorizontalAlign(Player_Rules_Label,"left",false) guiSetFont(Player_Rules_Label,"default-bold-small") Player_Rules_Memo = guiCreateMemo(25,105,315,401,"1. Be nice to admins and don't interrupt their work.\n\n2. Do not swear or spam because that will result in a KICK.If you do it several times it will result in a BAN!\n\n3. Do not CHEAT / HACK or use any other 3rd party software because that will result in a INSTANT BAN!\n\n4. If you are experienced in scripting you can freely ask our admins and maybe they let you work.\n\n5. Have fun!",false,SHC_Testing_Server_Rules) Member_Rules_Memo = guiCreateMemo(357,108,315,397,"1. Be nice to players and respect them.\n\n2. In this server you can test your new Resources/Scripts.\n\n3.If some player is asking for help in scripting you can help him but its your choice.\n\n4. As a Member you also must respect Player Rules.\n\n\n5. Have fun!",false,SHC_Testing_Server_Rules) Member_Rules_Label = guiCreateLabel(442,88,105,64,"Member Rules",false,SHC_Testing_Server_Rules) guiLabelSetColor(Member_Rules_Label,0,0,255) guiLabelSetVerticalAlign(Member_Rules_Label,"top") guiLabelSetHorizontalAlign(Member_Rules_Label,"left",false) guiSetFont(Member_Rules_Label,"default-bold-small") GUIEditor_Label[1] = guiCreateLabel(165,38,369,22,"This is a newly created server so this will be constantly updated!",false,SHC_Testing_Server_Rules) guiLabelSetColor(GUIEditor_Label[1],255,0,0) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) MTA_Image = guiCreateStaticImage(264,529,163,106,"images/mtalogo.png",false,SHC_Testing_Server_Rules) I_accept_rules_Button = guiCreateButton(16,556,238,69,"I accept rules!",false,SHC_Testing_Server_Rules) I_dont_accept_rules = guiCreateButton(430,554,242,71,"I dont accept rules!",false,SHC_Testing_Server_Rules) addEventHandler("onClientGUIClick", I_accept_rules_Button, acceptRules, false) end ) function acceptRules(button) if button == "left" then guiSetVisible( GUIEditor_Window[1], false) showCursor(false,false) outputChatBox("Thank you for accepting our rules.Have fun!") end end But... When I click the button it outputs the message correctly and it removes cursor but it doesn't close the window. What is the problem? Not only that... it doesn't even show the image which it should. Link to comment
Scooby Posted January 1, 2011 Share Posted January 1, 2011 you know you have 2 gui windows here? GUIEditor_Window[1] and SHC_Testing_Server_Rules MTA_Image = guiCreateStaticImage(264,529,163,106,"images/mtalogo.png",false,SHC_Testing_Server_Rules) is in the other window > guiSetVisible( GUIEditor_Window[1], false) it looks like youre making it more complicated than it needs to be. just read through what youre doing. the tables youve made at the top: GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} im guessing these are created by the gui editor... but its also an easy way to keep track of what youre doing, if you keep all the info to each window in theses tables. so u would have all your info in this window in: GUIEditor_Window[1] and all the buttons: GUIEditor_Button[1], GUIEditor_Button[2], GUIEditor_Button[3] and so on same with all the labels and memos. i'll let you look at what you have, if youre still stuck, say so and i'll help you more. Link to comment
proracer Posted January 1, 2011 Author Share Posted January 1, 2011 Thanks for all the help.Couldn't manage with that messed up GUI Window so I made new one.It works now thanks very much 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