Taalasmaa Posted July 19, 2009 Share Posted July 19, 2009 (edited) --- Edited October 4, 2009 by Guest Link to comment
Remp Posted July 20, 2009 Share Posted July 20, 2009 you've already added the onClientGUIClick event handler, so first you need to create your "Warp" function. You can check the source in the warp function to see which button was pressed and set spawn coordinates accordingly You will then need to use triggerServerEvent() to tell the server where and when to spawn, and then create a function serverside to spawn the player Your code should look something like this: Clientside function Warp(button,state) -- when they click with the left mouse button if button == "left" and state == "down" then -- if they clicked the home button if source == Button[1] then -- change 0,0,0 here to the Home coordinates triggerServerEvent("SpawnPlayerFromGUI",getLocalPlayer(),0,0,0) -- if they clicked the Grove. St button elseif source == Button[2] then -- change 0,0,0 here to the Grove. St coordinates triggerServerEvent("SpawnPlayerFromGUI",getLocalPlayer(),0,0,0) -- if they clicked the Pirate Ship button elseif source == Button[3] then -- change 0,0,0 here to the Pirate Ship coordinates triggerServerEvent("SpawnPlayerFromGUI",getLocalPlayer(),0,0,0) -- etc end end end Serverside function spawnThePlayer(x,y,z) -- spawn the player at the specified coordinates spawnPlayer(source,x,y,z) end -- add the event, this will be triggered when you click the gui addEvent("SpawnPlayerFromGUI",true) -- call the function spawnThePlayer when the event is triggered addEventHandler("SpawnPlayerFromGUI",getRootElement(),spawnThePlayer) This is just example code so you will need to fill in the areas that are unfinished and tweak it to your exact needs If there is anything in there you dont understand i suggest reading the relavent wiki page for that function and make sure you are familiar with scripting GUI Link to comment
Taalasmaa Posted July 20, 2009 Author Share Posted July 20, 2009 Thanks, worked like dream, but How Can I make it showing when player join+ when player dead.. Link to comment
Remp Posted July 20, 2009 Share Posted July 20, 2009 In your original code the gui will be recreated every time you show it, id suggest moving the gui creation code into "onStart" so its only created once (when you join the server) and changing your "Window" function to just show/hide it To have it show when a player dies, use the event onClientPlayerWasted to call a function that shows the gui Your new code would then be: Window = {} Button = {} function Window() if guiGetVisible(Window[1]) then guiSetVisible(Window[1],false) showCursor(false) else guiSetVisible(Window[1],true) showCursor(true) end end addCommandHandler("spawnpoint",changeWindow) function onStart() Window[1] = guiCreateWindow(300,173,250,350,"Finland RPG Spawnpoints",false) Button[1] = guiCreateButton(0.061728395521641,0.10330578684807,0.85185188055038,0.10743801295757,"Home",true,Window[1]) Button[2] = guiCreateButton(0.061728395521641,0.23553718626499,0.85185188055038,0.10743801295757,"Grove. St",true,Window[1]) Button[3] = guiCreateButton(0.061728395521641,0.37190082669258,0.85185188055038,0.10743801295757,"Pirate Ship",true,Window[1]) Button[4] = guiCreateButton(0.061728395521641,0.50413221120834,0.85185188055038,0.10743801295757,"Jefferson",true,Window[1]) Button[5] = guiCreateButton(0.061728395521641,0.63636362552643,0.85185188055038,0.10743801295757,"Wang Cars",true,Window[1]) Button[6] = guiCreateButton(0.055555555969477,0.77272725105286,0.85802471637726,0.16528925299644,"Close Menu",true,Window[1]) guiWindowSetSizable ( Window[1], false ) addEventHandler ( "onClientGUIClick", Button[1], Warp ) addEventHandler ( "onClientGUIClick", Button[2], Warp ) addEventHandler ( "onClientGUIClick", Button[3], Warp ) addEventHandler ( "onClientGUIClick", Button[4], Warp ) addEventHandler ( "onClientGUIClick", Button[5], Warp ) addEventHandler ( "onClientGUIClick", Button[6], close ) guiSetVisible(Window[1],true) showCursor(true) bindKey ("F4", "down", changeWindow ) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),onStart) function playerWasted() -- if the local player died (ie: you died) if source == getLocalPlayer() then -- show the window guiSetVisible(Window[1],true) showCursor(true) end end addEventHandler("onClientPlayerWasted",getRootElement(),playerWasted) Link to comment
tinnetju Posted August 27, 2009 Share Posted August 27, 2009 Uuhhh guys could u explain me where to put that code. It looks realy good and i want to add some cool scripts to my server. So could u explain me what files i have to make? And if u explained me that and i putted then in an map do i have to make an .rar file from it 2? Thank u very much Link to comment
Taalasmaa Posted August 27, 2009 Author Share Posted August 27, 2009 Uuhhh guys could u explain me where to put that code.It looks realy good and i want to add some cool scripts to my server. So could u explain me what files i have to make? And if u explained me that and i putted then in an map do i have to make an .rar file from it 2? Thank u very much STUPID!!! Do your own code! This isn't for copy you gay! Do your own code, we don't tell it for you! EDIT: Do not copy this code, there's my copyrights, i'm using this script in my server, so I don't wanna, that other server uses this. I know, that you willnot use this code, if you have respect for mta. Link to comment
robhol Posted August 27, 2009 Share Posted August 27, 2009 Talasma, that's the very stupidest thing I can remember seeing around here... you did post the code publically... Link to comment
tinnetju Posted June 11, 2011 Share Posted June 11, 2011 Okaaaaaaay soz dude, and i would never, ever put this online or something... Only private server, but i won't copy it Link to comment
Castillo Posted June 11, 2011 Share Posted June 11, 2011 This is a really old topic, why are you posting here? as you can see lastest post was in 2009. P.S: Someone could re-make that code and alot easier I think. 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