Jump to content

How do i make a GPS?


Recommended Posts

Hi! I want to make a script, in which for example the player gives 2 xyz positions, and in every 50 meters there would be a marker, which would lead the player to the position. I am aware, that there is a script by default, but i can't really read it. So anyone please explain me, how to do it?

Link to comment

you can use tables to write xyz marker positions like that:

markers = {
{x,y,z},
{x2,y2,z2},
}

Then you can detect markers with onClientMarkerHit or onMarkerHit. This events gives you a possibility to move to the next step (create next marker).

You can use here setElementData to select next marker.

Example:

markers = {
	{x,y,z},
	{x2,y2,z2},
}

function next_mark(pl)
	if not pl then pl = localPlayer
	local num = getElementData(pl,"currentMarker") or 1
  	local cur_x,cur_y,cur_z = unpack( markers[num] )
	checkpoint = createMarker(cur_x,cur_y,cur_z,"checkpoint",2)
	num = num + 1
	setElementData(pl,"currentMarker",num)
end

addEventHandler("onClientMarkerHit",getRootElement(),function(player)
	destroyElement(checkpoint)
	next_mark(player)
end)

I'm not sure that it works\\ But i hope that you understood me xD

  • Thanks 1
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...