Jump to content

[HELP] Creating a 'Warp' button


Ab-47

Recommended Posts

Ahoi guys, I'm new in the forum thing so forgive me if I messed up with any parts of the rules or creating a topic guidlines :)

-------------

OK So, I need help with 'Creating a warp button' that actually warps, I'm a regular scripter just got of from newbie ;o but.. I don't get how I can make a part of my script work.

-------------

What does my script do?

Well basically I made a GUI, random GUI which I thought I'd turn it into a warping thing and extra text or w/e and so, I created a button where when you click it, you'd be warped to that specific location with an outputChatBox message.

What's wrong with the script?

Well there's 2 things which I'm not quiet getting, the first is the outputChatBox color, I added the outputChatBox like this:

outputChatBox ( "text", 255, 0, 0 ) 

which I tried making it red, then discovered that I can also use:

outputChatBox ( "text", thePlayer, 0, 0 ) 

whilst adding thePlayer after the function variable.

OK, so, the other problem (the main problem) is the Warp button. What's not working is, when I click the button the outputChatBox message comes (yet in white, not red) and doesn't warp. Nor do I get an argument error etc..

-------------

Here's the overall script:

function GUI () 
Window = guiCreateWindow ( 88, 66, 617, 472, "", false ) 
showCursor ( true ) 
guiWindowSetMovable ( Window, false ) 
guiWindowSetSizable ( Window, false ) 
guiCreateStaticImage( 110, 10, 400, 200, "fDrD0.png", false, Window ) 
CloseButton = guiCreateButton ( 548, 368, 168, 74, "Close", false, Window ) 
WarpButton = guiCreateButton ( 300, 150, 150, 100, "Warp", false, Window ) 
guiSetFont ( CloseButton, "default-bold-small" ) 
for k, v in ipairs ( files ) do 
        local data = split ( v, string.byte (";") ) 
        local memo = guiCreateMemo ( 150, 300, 350, 120, "Text", false, Window) 
        guiMemoSetReadOnly ( memo, true) 
end 
  
addEventHandler("onClientGUIClick", WarpButton, 
function warp ( thePlayer ) 
         if source == WarpButton then 
             setElementPosition ( thePlayer, 2040, 1478, 10.67 ) 
             outputChatBox ( "You have been warped to the bank", thePlayer, 255, 0, 0 ) 
         end 
    end 
    ) 
  
addEventHandler( "onClientGUIClick", CloseButton, 
function() 
         if source == CloseButton then 
             guiSetVisible( Window, false ) 
             showCursor( false ) 
             guiSetInputEnabled( false ) 
         end 
     end 
     ) 
end 
addCommandHandler ( "opengui", GUI ) 

where the main problem I have is here:

  
function GUI () 
WarpButton = guiCreateButton ( 300, 150, 150, 100, "Warp", false, Window ) 
  
addEventHandler("onClientGUIClick", WarpButton, 
function warp ( thePlayer ) 
         if source == WarpButton then 
             setElementPosition ( thePlayer, 2040, 1478, 10.67 ) 
             outputChatBox ( "You have been warped to the bank", thePlayer, 255, 0, 0 ) 
         end 
    end 
    ) 
end 

So if anyone can help me, I'd be more than thankful. Thanks for reading, sorry if it's a bit too long, the fault is actually minor but I'm just too dumb atm to figure out what the hell it is D: Cya guys

Link to comment

Check functiona rguments for event onClientGUIClick

First argument is the BUTTON. Obviously SOURCE is the GUI element that was clicked. You use localPlayer only and it's fine.

function warp (  ) 
         if source == WarpButton then 
             setElementPosition ( localPlayer, 2040, 1478, 10.67 ) 
             outputChatBox ( "You have been warped to the bank", 255, 0, 0 ) 
         end 
    end 
    ) 

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