Xeno Posted January 26, 2010 Share Posted January 26, 2010 (edited) Hey... Im makeing a GUI, and i want when a button is pressed for it 2 spawn me somewhere, this hole script is working but one problem, its not teleporting me! help! Here is the code of the client and the server. Server side function moveThePlayer(-2222,-2222,-2222,4) -- check we have a position and rotation if x and y and z and rotation then -- get the players current skin, so we can spawn them again without losing it local skin = getElementModel(client) -- spawn the player spawnPlayer(client,-2222,-2222,-2222,rotation,284) -- make sure the players camera is on his character setCameraTarget(client,client) end end Client function privateclans() wdwLogin = guiCreateWindow(226,146,372,233,"[Private Clans]",false) guiWindowSetMovable(wdwLogin,false) guiWindowSetSizable(wdwLogin,false) tabpanel = guiCreateTabPanel(0.0242,0.0858,0.9489,0.8755,true,wdwLogin) tab1 = guiCreateTab("Info",tabpanel) login = guiCreateButton(0.010,0.100,0.970,0.800,"This whole window is only for People who have joined one of the Private Clans, if you are not a member of one of these private clans, please press F3",true,tab1) tab2 = guiCreateTab("DE login",tabpanel) login = guiCreateButton(0.010,0.100,0.970,0.800,"This Tab is ONLY for MP members. Click on this tab to login. To Join come on the server regulary and be active on our site and forum [url=http://www.mtaproject.com]http://www.mtaproject.com[/url]",true,tab2) tab3 = guiCreateTab("Bikers Login",tabpanel) Information= guiCreateButton ( 0.010, 0.100, 0.970, 0.800, "This Tab is only for biker members, you can only join the bikers on pure invite! To be invited come on the server regulary and be active on our site and forum [url=http://www.mtaproject.com]http://www.mtaproject.com[/url]", true, tab3 ) tab4 = guiCreateTab("Navy Login",tabpanel) Information2= guiCreateButton ( 0.010, 0.100, 0.970, 0.800, "This Tab is only for Navy members, you can only join the bikers on pure invite! To be invited come on the server regulary and be active on our site and forum [url=http://www.mtaproject.com]http://www.mtaproject.com[/url]", true, tab4 ) tab5 = guiCreateTab("RAF Login",tabpanel) Information3= guiCreateButton ( 0.010, 0.100, 0.970, 0.800, "This Tab is only for RAF members, you can only join the bikers on pure invite! To be invited come on the server regulary and be active on our site and forum [url=http://www.mtaproject.com]http://www.mtaproject.com[/url]", true, tab5 ) guiSetVisible(wdwLogin,false) addEventHandler("onClientGUIClick", information, teleportPlayer, false) addEventHandler("onClientGUIClick", information2, teleportPlayer, false) addEventHandler("onClientGUIClick", information3, teleportPlayer, false) bindKey("F3" , "down" , windowToggle) end function windowToggle() if (guiGetVisible(wdwLogin) == true) then guiSetVisible(wdwLogin, false) showCursor(false) elseif (guiGetVisible(wdwLogin) == false) then guiSetVisible(wdwLogin, true) showCursor(true) end end function teleportPlayer(button,state) if button == "left" and state == "up" then if source == teleportButtonLS then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1479.6,-1612.8,14.0,0) outputChatBox("Welcome to the DE base") -- otherwise, if the player clicked on the SF teleport button elseif source == teleportButtonSF then -- trigger the server with our San Fierro coordinates triggerServerEvent("movePlayerToPosition",getLocalPlayer(),-2265.5,534.0,35.0,270) -- output a message to the player outputChatBox("Welcome to the Bikers base!") -- otherwise, if the player clicked on the LV teleport button elseif source == teleportButtonLV then -- trigger the server with our Las Venturas coordinates triggerServerEvent("movePlayerToPosition",getLocalPlayer(),2036.9,1545.2,10.8,270) -- output a message to the player outputChatBox("Wecome to the Navey's Ship!") end -- hide the window and all the components guiSetVisible(teleportWindow, false) -- hide the mouse cursor showCursor(false) end end addEventHandler( "onClientResourceStart" , getResourceRootElement(getThisResource()), privateclans) Edited January 26, 2010 by Guest Link to comment
Xeno Posted January 26, 2010 Author Share Posted January 26, 2010 (edited) Hey... Im makeing a GUI, and i want when a button is pressed for it 2 spawn me somewhere, this hole script is working but one problem, its not teleporting me! help! Here is the code of the client and the server. Server side function moveThePlayer(-2222,-2222,-2222,4) -- check we have a position and rotation if x and y and z and rotation then -- get the players current skin, so we can spawn them again without losing it local skin = getElementModel(client) -- spawn the player spawnPlayer(client,-2222,-2222,-2222,rotation,284) -- make sure the players camera is on his character setCameraTarget(client,client) endend Client function privateclans()wdwLogin = guiCreateWindow(226,146,372,233,"[Private Clans]",false)guiWindowSetMovable(wdwLogin,false)guiWindowSetSizable(wdwLogin,false)tabpanel = guiCreateTabPanel(0.0242,0.0858,0.9489,0.8755,true,wdwLogin)tab1 = guiCreateTab("Info",tabpanel)login = guiCreateButton(0.010,0.100,0.970,0.800,"This whole window is only for People who have joined one of the Private Clans, if you are not a member of one of these private clans, please press F3",true,tab1)tab2 = guiCreateTab("DE login",tabpanel)login = guiCreateButton(0.010,0.100,0.970,0.800,"This Tab is ONLY for MP members. Click on this tab to login. To Join come on the server regulary and be active on our site and forum [url=http://www.mtaproject.com]http://www.mtaproject.com[/url]",true,tab2)tab3 = guiCreateTab("Bikers Login",tabpanel)Information= guiCreateButton ( 0.010, 0.100, 0.970, 0.800, "This Tab is only for biker members, you can only join the bikers on pure invite! To be invited come on the server regulary and be active on our site and forum [url=http://www.mtaproject.com]http://www.mtaproject.com[/url]", true, tab3 )tab4 = guiCreateTab("Navy Login",tabpanel)Information2= guiCreateButton ( 0.010, 0.100, 0.970, 0.800, "This Tab is only for Navy members, you can only join the bikers on pure invite! To be invited come on the server regulary and be active on our site and forum [url=http://www.mtaproject.com]http://www.mtaproject.com[/url]", true, tab4 )tab5 = guiCreateTab("RAF Login",tabpanel)Information3= guiCreateButton ( 0.010, 0.100, 0.970, 0.800, "This Tab is only for RAF members, you can only join the bikers on pure invite! To be invited come on the server regulary and be active on our site and forum [url=http://www.mtaproject.com]http://www.mtaproject.com[/url]", true, tab5 )guiSetVisible(wdwLogin,false)addEventHandler("onClientGUIClick", information, teleportPlayer, false) addEventHandler("onClientGUIClick", information2, teleportPlayer, false) addEventHandler("onClientGUIClick", information3, teleportPlayer, false)bindKey("F3" , "down" , windowToggle)end function windowToggle()if (guiGetVisible(wdwLogin) == true) then guiSetVisible(wdwLogin, false) showCursor(false)elseif (guiGetVisible(wdwLogin) == false) then guiSetVisible(wdwLogin, true) showCursor(true) endend function teleportPlayer(button,state) if button == "left" and state == "up" then if source == teleportButtonLS then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1479.6,-1612.8,14.0,0) outputChatBox("Welcome to the DE base") -- otherwise, if the player clicked on the SF teleport button elseif source == teleportButtonSF then -- trigger the server with our San Fierro coordinates triggerServerEvent("movePlayerToPosition",getLocalPlayer(),-2265.5,534.0,35.0,270) -- output a message to the player outputChatBox("Welcome to the Bikers base!") -- otherwise, if the player clicked on the LV teleport button elseif source == teleportButtonLV then -- trigger the server with our Las Venturas coordinates triggerServerEvent("movePlayerToPosition",getLocalPlayer(),2036.9,1545.2,10.8,270) -- output a message to the player outputChatBox("Wecome to the Navey's Ship!") end -- hide the window and all the components guiSetVisible(teleportWindow, false) -- hide the mouse cursor showCursor(false) end end addEventHandler( "onClientResourceStart" , getResourceRootElement(getThisResource()), privateclans) Edited January 26, 2010 by Guest Link to comment
Xeno Posted January 26, 2010 Author Share Posted January 26, 2010 i debuged it and found these 3 lines were the rong part, but wat is rong? addEventHandler("onClientGUIClick", information, teleportPlayer, false) addEventHandler("onClientGUIClick", information2, teleportPlayer, false) addEventHandler("onClientGUIClick", information3, teleportPlayer, false) Link to comment
Xeno Posted January 26, 2010 Author Share Posted January 26, 2010 i debuged it and found these 3 lines were the rong part, but wat is rong? addEventHandler("onClientGUIClick", information, teleportPlayer, false) addEventHandler("onClientGUIClick", information2, teleportPlayer, false) addEventHandler("onClientGUIClick", information3, teleportPlayer, false) Link to comment
robhol Posted January 26, 2010 Share Posted January 26, 2010 Please either pastebin your code or post it in [lua] [/lua] tags. Reading code like that is a nightmare. Also learn to indent code properly if you want people to look at it without getting migraines... Also, the edit button on the top right of your post is there for a reason. Link to comment
robhol Posted January 26, 2010 Share Posted January 26, 2010 Please either pastebin your code or post it in [lua] [/lua] tags. Reading code like that is a nightmare. Also learn to indent code properly if you want people to look at it without getting migraines... Also, the edit button on the top right of your post is there for a reason. Link to comment
Xeno Posted January 26, 2010 Author Share Posted January 26, 2010 Ok sorry, but what is rong?? ill but in the code thing . addEventHandler("onClientGUIClick",privateclans,information,false) addEventHandler("onClientGUIClick",privateclans,information2,false) addEventHandler("onClientGUIClick",privateclans,information3,false) Link to comment
Xeno Posted January 26, 2010 Author Share Posted January 26, 2010 Ok sorry, but what is rong?? ill but in the code thing . addEventHandler("onClientGUIClick",privateclans,information,false)addEventHandler("onClientGUIClick",privateclans,information2,false)addEventHandler("onClientGUIClick",privateclans,information3,false) Link to comment
robhol Posted January 26, 2010 Share Posted January 26, 2010 You can't really post like 2% of your code and expect us to know instantly what's wrong. Post all of it, then maybe we can help you. In the meantime, make sure you've got the functions correct (the order in which you provide arguments, etc.) and that you're giving the right data. Link to comment
robhol Posted January 26, 2010 Share Posted January 26, 2010 You can't really post like 2% of your code and expect us to know instantly what's wrong. Post all of it, then maybe we can help you. In the meantime, make sure you've got the functions correct (the order in which you provide arguments, etc.) and that you're giving the right data. Link to comment
Xeno Posted January 26, 2010 Author Share Posted January 26, 2010 Iv given you all of it at the top... Link to comment
Xeno Posted January 26, 2010 Author Share Posted January 26, 2010 Iv given you all of it at the top... Link to comment
Remp Posted January 26, 2010 Share Posted January 26, 2010 'information' is not the same as 'Information'. Your button variables use a capital I, not lower case i Additionally, you cannot have variables that start with a number as you do in your serverside function function moveThePlayer(-2222,-2222,-2222,4) ... If your intention is to spawn the player at -2222, -2222, -2222 (which is probably not a good idea, -2222 z is a long way down) you will need to define the x,y,z variables and instead pass your position from the client in your triggerServerEvent lines function moveThePlayer(x,y,z,rotation) You also need to modify your teleportPlayer function to look for your 'Information' variables in source, rather than the old 'teleportButton' variables: function teleportPlayer(button,state) if button == "left" and state == "up" then if source == Information then ... Link to comment
Remp Posted January 26, 2010 Share Posted January 26, 2010 'information' is not the same as 'Information'. Your button variables use a capital I, not lower case i Additionally, you cannot have variables that start with a number as you do in your serverside function function moveThePlayer(-2222,-2222,-2222,4) ... If your intention is to spawn the player at -2222, -2222, -2222 (which is probably not a good idea, -2222 z is a long way down) you will need to define the x,y,z variables and instead pass your position from the client in your triggerServerEvent lines function moveThePlayer(x,y,z,rotation) You also need to modify your teleportPlayer function to look for your 'Information' variables in source, rather than the old 'teleportButton' variables: function teleportPlayer(button,state) if button == "left" and state == "up" then if source == Information then ... Link to comment
Xeno Posted January 27, 2010 Author Share Posted January 27, 2010 nope still doesent work Link to comment
Xeno Posted January 27, 2010 Author Share Posted January 27, 2010 nope still doesent work Link to comment
Remp Posted January 27, 2010 Share Posted January 27, 2010 Ok, so post your new code with the changes you made the more you help us understand what you are doing the more we can help you Link to comment
Remp Posted January 27, 2010 Share Posted January 27, 2010 Ok, so post your new code with the changes you made the more you help us understand what you are doing the more we can help you 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