Jump to content

[REQ]Help in spawnpoints!


Recommended Posts

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

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
  • 1 month later...

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
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
  • 1 year later...

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