Jump to content

Player hit the marker


Recommended Posts

Posted

Hello, this is just a little question, how can I know if a player already hit a marker? I mean, I created a marker, then executed certain functions once the player hit the marker, but it's executing those functions again when the player hit the marker again. How can I make a restriction for that? I just want it works only once (only when the player hit the marker for the first time).

Someone told me to use tables so I can get the players' names on it, then make a restriction with those names, but I don't know how to start. can someone give me a hand with useful functions that I can use to make it works? thanks for taking your time on reviewing my topic. 

Posted

you don't have  to make tables :L

just setElementData for the player who enter the marker
and when he hit it 
if getElementData
if its true then retrurn end
and if its false continue the function

Posted
local enteredPlayers = {}
local myMarker = createMarker(0, 0, 2.5, "cylinder", 2.0, 255, 0, 0, 150)

function MarkerHit( hitElement, matchingDimension )
    if getElementType( hitElement ) == "player" and matchingDimension then
	    if (not enteredPlayers[hitElement]) then
		    enteredPlayers[hitElement] = true
			outputChatBox(getPlayerName(hitElement).." entered the marker for the first time.", hitElement, 0, 255, 0)
		else
		    outputChatBox(getPlayerName(hitElement).." entered the marker before.", hitElement, 255, 0, 0)
		end
	end
end
addEventHandler( "onMarkerHit", myMarker, MarkerHit ) 

 

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