Jump to content

checkpoint


Recommended Posts

Hello friends,
I need your help! I explain that I have an event panel to create careers for players on my freeroam server

Through the panel I must create all racing checkpoint.

And what I want to achieve is that when the player passes over the point, that disappears and the next checkpoint comes out 

I leave my code tell me how I can achieve this

Or if they have a similar panel, I would like them to contribute with the

yxNYi5u.jpg

---Server
blip = {}
marker = {}
function event ()
	call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0)
	local x, y, z = getElementPosition (source)
	local maxBlip = #blip -- with this you have the contents of the table.
	local maxMarker = #marker
	blip[maxBlip + 1] = createBlip (x, y, z, 49)
	marker[maxMarker + 1] = createMarker (x, y, z, "checkpoint", 2, 135, 191, 255, 200)
end
addEvent ("event", true)
addEventHandler ("event", root, event)

 

Edited by xRGamingx
Link to comment
  • Moderators

Something like this should work:

local markers = 
{
	{x, y, z};
	{x, y, z};
}

local curMarkerBlip
local curMarker
local ID

function event()
	call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0)
	createCheckpoint( 1 )
  	ID = 1
end
addEvent ("event", true)
addEventHandler ("event", root, event)

function createCheckpoint(ID)
	if ID then
		if isElement(curMarker) and isElement(curMarkerBlip) then
			destroyElement(curMarker)
			destroyElement(curMarkerBlip)
		end
		local x, y, z = unpack(markers[tonumber(ID)])
		curMarker = createMarker( x, y, z, "checkpoint", 2, 135, 191, 255, 200 )
		curMarkerBlip = createBlipAttachedTo( curMarker, 49 )
		
		return true
	end
	return false
end

addEventHandler( "onClientMarkerHit", resourceRoot, 
function (hitPlayer, dim)
	if (curMarker and source == curMarker and hitPlayer == localPlayer and dim) then
		ID = ID + 1
		if ID > #markers then ID = 1 end
		createCheckpoint( ID ) -- create the next checkpoint
	end
end )

 

Edited by DNL291
Link to comment
20 minutes ago, DNL291 said:

Something like this should work:


local markers = 
{
	{x, y, z};
	{x, y, z};
}

local curMarkerBlip
local curMarker
local ID

function event()
	call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0)
	createCheckpoint( 1 )
  	ID = 1
end
addEvent ("event", true)
addEventHandler ("event", root, event)

function createCheckpoint(ID)
	if ID then
		if isElement(curMarker) and isElement(curMarkerBlip) then
			destroyElement(curMarker)
			destroyElement(curMarkerBlip)
		end
		local x, y, z = unpack(markers[tonumber(ID)])
		curMarker = createMarker( x, y, z, "checkpoint", 2, 135, 191, 255, 200 )
		curMarkerBlip = createBlipAttachedTo( curMarker, 49 )
		
		return true
	end
	return false
end

addEventHandler( "onClientMarkerHit", resourceRoot, 
function (hitPlayer, dim)
	if (curMarker and source == curMarker and hitPlayer == localPlayer and dim) then
		ID = ID + 1
		if ID > #markers then ID = 1 end
		createCheckpoint( ID ) -- create the next checkpoint
	end
end )

 

NofknNM.png

@DNL291i6ID0Ql.png

Edited by xRGamingx
Link to comment
3 minutes ago, DNL291 said:

Show here the code you're using. Post it using the formatting for Lua:

MSHAyJ3.png

Also, type /debugscript 3 when testing your script.

friend the debug script 3 is activated and does not throw me error


local markers = 
{
	{1942.0526123047, -1702.3355712891, 13.3828125};
	{1942.302734375, -1715.2150878906, 12.792504310608};
	
}

local curMarkerBlip
local curMarker
local ID

function event()
	call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0)
	createCheckpoint( 1 )
  	ID = 1
end
addEvent ("event", true)
addEventHandler ("event", root, event)

function createCheckpoint(ID)
	if ID then
		if isElement(curMarker) and isElement(curMarkerBlip) then
			destroyElement(curMarker)
			destroyElement(curMarkerBlip)
		end
		local x, y, z = unpack(markers[tonumber(ID)])
		curMarker = createMarker( x, y, z, "checkpoint", 2, 135, 191, 255, 200 )
		curMarkerBlip = createBlipAttachedTo( curMarker, 0 )
		
		return true
	end
	return false
end

addEventHandler( "onClientMarkerHit", resourceRoot, 
function (hitPlayer, dim)
	if (curMarker and source == curMarker and hitPlayer == localPlayer and dim) then
		ID = ID + 1
		if ID > #markers then ID = 1 end
		createCheckpoint( ID ) -- create the next checkpoint
	end
end )

 

Link to comment
  • Moderators
2 hours ago, xRGamingx said:

friend the debug script 3 is activated and does not throw me error


local markers = 
{
	{1942.0526123047, -1702.3355712891, 13.3828125};
	{1942.302734375, -1715.2150878906, 12.792504310608};
	
}

local curMarkerBlip
local curMarker
local ID

function event()
	call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0)
	createCheckpoint( 1 )
  	ID = 1
end
addEvent ("event", true)
addEventHandler ("event", root, event)

function createCheckpoint(ID)
	if ID then
		if isElement(curMarker) and isElement(curMarkerBlip) then
			destroyElement(curMarker)
			destroyElement(curMarkerBlip)
		end
		local x, y, z = unpack(markers[tonumber(ID)])
		curMarker = createMarker( x, y, z, "checkpoint", 2, 135, 191, 255, 200 )
		curMarkerBlip = createBlipAttachedTo( curMarker, 0 )
		
		return true
	end
	return false
end

addEventHandler( "onClientMarkerHit", resourceRoot, 
function (hitPlayer, dim)
	if (curMarker and source == curMarker and hitPlayer == localPlayer and dim) then
		ID = ID + 1
		if ID > #markers then ID = 1 end
		createCheckpoint( ID ) -- create the next checkpoint
	end
end )

 

I've tested this code and it worked for me.

Link to comment
On 4/6/2018 at 22:46, DNL291 said:

I've tested this code and it worked for me.

Hello friend, this still does not work..

pass me the code the way you use it in your test for me to put it as is in mine

because it still does not work, the first checkpoint appears, but when you touch it it does not disappear to see the next one :/ 

Link to comment
  • Moderators

If nothing happens when you hit the marker, something is wrong, so learn how to debug:

Also, make sure the marker really belongs to the script and your player dimension is the same as the marker.

Edited by DNL291
Link to comment

Try it this way, since you are trying to make the marker disappear in a vehicle on the picture, but the hitElement must be the localPlayer based on the previous code.

addEventHandler( "onClientMarkerHit", resourceRoot, 
function (hitElement, dim)
	if (curMarker and source == curMarker and (hitElement == localPlayer or hitElement == getPedOccupiedVehicle(localPlayer)) and dim) then
		ID = ID + 1
		if ID > #markers then ID = 1 end
		createCheckpoint( ID ) -- create the next checkpoint
	end
end )

Or just try deleting it and then test if and see if it works.

addEventHandler( "onClientMarkerHit", resourceRoot, 
function (hitElement, dim)
	if (curMarker and source == curMarker and dim) then
		ID = ID + 1
		if ID > #markers then ID = 1 end
		createCheckpoint( ID ) -- create the next checkpoint
	end
end )

 

Edited by Dzsozi (h03)
Link to comment
1 hour ago, Dzsozi (h03) said:

Try it this way, since you are trying to make the marker disappear in a vehicle on the picture, but the hitElement must be the localPlayer based on the previous code.


addEventHandler( "onClientMarkerHit", resourceRoot, function (hitElement, dim)	if (curMarker and source == curMarker and (hitElement == localPlayer or hitElement == getPedOccupiedVehicle(localPlayer)) and dim) then		ID = ID + 1		if ID > #markers then ID = 1 end		createCheckpoint( ID ) -- create the next checkpoint	endend )

Or just try deleting it and then test if and see if it works.


addEventHandler( "onClientMarkerHit", resourceRoot, function (hitElement, dim)	if (curMarker and source == curMarker and dim) then		ID = ID + 1		if ID > #markers then ID = 1 end		createCheckpoint( ID ) -- create the next checkpoint	endend )

 

Friend does not work with any :(  What I want to achieve is to create race events within my RPG mode server with checkpoint help plz .

Or if you have an equal script to help me

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