megaman54 Posted November 13, 2010 Share Posted November 13, 2010 Hi i tryed to make a gui with some script. I made a close button (some others too). When i press the close button nothing happens, here is the code: function closeWindow() if (source == GUIEditor_Button[2]) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end end addEventHandler("onClientGUIClick", getLocalPlayer(), closeWindow) Help me ASAP! EDIT: When i changed the number of "end" at the end, debugscript says "expected near 'end' ". Link to comment
Static-X Posted November 13, 2010 Share Posted November 13, 2010 function closeWindow() guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2], closeWindow, false ) Link to comment
megaman54 Posted November 13, 2010 Author Share Posted November 13, 2010 OK thx! but now i got another problem with the same script (server side now): function crashThem(playerName) setElementVelocity(getPlayerFromName(playerName), 999, 999, 999) end addEvent("onPlayerCrash", true) addEventHandler("onPlayerCrash", getRootElement(), crashThem) giving error: "bad argument @ 'setElementVelocity' ". Link to comment
Aibo Posted November 13, 2010 Share Posted November 13, 2010 OK thx! but now i got another problem with the same script (server side now): function crashThem(playerName) setElementVelocity(getPlayerFromName(playerName), 999, 999, 999) end addEvent("onPlayerCrash", true) addEventHandler("onPlayerCrash", getRootElement(), crashThem) giving error: "bad argument @ 'setElementVelocity' ". is playerName passed to the handler? is playerName really a player NAME? why dont you use source (i bet the source of the event is player)? p.s.: that is one crazy velocity setting. Link to comment
dzek (varez) Posted November 13, 2010 Share Posted November 13, 2010 setting velocity over around 1.5 has no effect on peds. on vehicles can crash/hang client game. Your code is UGLY. Solution: http://en.wikipedia.org/wiki/Indent_style Link to comment
megaman54 Posted November 13, 2010 Author Share Posted November 13, 2010 I dont care if the code is ugly. Why it even should be beatyful? And here is the client side code that triggers the server side event: function crashPlayer() if (source == GUIEditor_Button[1]) then playerName = guiGetText(GUIEditor_Button[1]) triggerServerEvent("onPlayerCrash", getLocalPlayer(), playerName) end end end addEventHandler("onClientGUIClick", getLocalPlayer(), crashPlayer) The meaning of this script is to crash the specified players game, its like a kick but a harder kick! Link to comment
dzek (varez) Posted November 13, 2010 Share Posted November 13, 2010 Because after you write next 500 lines you won't be able to find anything, you won't know where each "if" or function are ending and such things. Also - some ppl won't read so messy code on forum and won't try to help. Why wasting 10 minutes (to find out that one "end" was in wrong place) because script creator is too lazy to press TAB few times? local maybeItsPlayer = getPlayerFromName(playerName) if (isElement(maybeItsPlayer)) then -- set velocity end The meaning of this script is to crash the specified players game, its like a kick but a harder kick! as i said - it won't work. velocity of players are limited by gta to rather LOW value - setting it to 999 will have not result. And your code won't work if player is in car. Link to comment
megaman54 Posted November 13, 2010 Author Share Posted November 13, 2010 Because after you write next 500 lines you won't be able to find anything, you won't know where each "if" or function are ending and such things.Also - some ppl won't read so messy code on forum and won't try to help. Why wasting 10 minutes (to find out that one "end" was in wrong place) because script creator is too lazy to press TAB few times? local maybeItsPlayer = getPlayerFromName(playerName) if (isElement(maybeItsPlayer)) then -- set velocity end The meaning of this script is to crash the specified players game, its like a kick but a harder kick! as i said - it won't work. velocity of players are limited by gta to rather LOW value - setting it to 999 will have not result. And your code won't work if player is in car. I wont write next 500 lines of code to this script because it doesn't need it. Maybe i just need to change the nice GUI to a boring command, thats all. Link to comment
dzek (varez) Posted November 13, 2010 Share Posted November 13, 2010 or learn to script? btw: i gave you the fix, whats wrong? Link to comment
megaman54 Posted November 13, 2010 Author Share Posted November 13, 2010 I dint understand your fix at all. Tell me one thing, how to use "if" thing? I copied that one from another script... Link to comment
dzek (varez) Posted November 13, 2010 Share Posted November 13, 2010 http://www.lua.org/pil/4.3.1.html 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