Jump to content

GUI Script not working?


megaman54

Recommended Posts

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

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

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

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

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