Jump to content

onClientMarkerHit


Cronoss

Recommended Posts

I'm making a marker-system, when the player hit the marker it deletes the current one, and creates a new one, the problem is that debugscript send me "expected element at argument 2, got nil", if I use "root" or "getRootElement()" in that part, it works but FOR EVERY other marker, so it's kinda chaotic...

 

(I'm scripting this in CLIENT-SIDE, because I only want the player who used the command can see the markers, not everybody)

 

I used:

------------------------Initial marker---------------------
function startGH()
	---------outputChatBox
	mark1 = createMarker(1888.5596923828,-2055.2121582031,13.3828125, "checkpoint", 1, 90, 255, 20) ------This is the first marker
end
addEvent("gah", true)
addEventHandler("gah", root, startGH)



--------------------------Marker Delete----------------
function markDelete(hitPlayer)
		iprint("1")
		if getElementType( hitPlayer ) == "player" and source == mark1 then
        	destroyElement(mark1)
        	local vehicle = getPedOccupiedVehicle(hitPlayer)
        	setElementFrozen(vehicle, true)
            -------outputChatBox
            setTimer(function ()
			-------outputChatBox
       			setElementFrozen(vehicle, false)
       			mark2 = createMarker() ---unnecessary info, second marker
       		end, 5000, 1)
    	end
    end
end
addEventHandler("onClientMarkerHit", mark1, markDelete) ------got nil

Also, I tried using "onMarkerHit" but didn't work, so "onClientMarkerHit" it's the only way that I know that could make possible my system

 

Maybe there's a better way to make a system like this but I don't know how, I tried using a table but it didn't work :/

Link to comment

you can limit it by using root and using if command actually so you can handle it in a single eventhandler

The nil error could possibly be because mark1 has not been created yet

example: 

function markerHandler(hitElement, matchingDimension)
   if(getElementType(hitElement) == "player") then
      
      if(source == mark1) then
         --codes here for mark1
      end

      if(source == mark2) then
         --codes here for mark2
      end

   end
end
addEventHandler("onClientMarkerHit", root, markerHandler)
Edited by Burak5312
  • Like 1
  • 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...