Jump to content

onMatkerHit problem


Recommended Posts

Hello,

I'm creating a house system, but I ran into a problem I can't solve.

I want to handle when a player hits a house entrance's marker, but it only works once, the second time I hit the marker, there's no server reaction.

  
function houseMarkerHit ( elem, matchingDimension ) 
    if getElementType ( elem ) == "player" then 
        outputChatBox ( "Marker hit", elem ) 
    end 
end 
  
addEventHandler ( "onMarkerHit", root, houseMarkerHit ) 
  

How could I solve this problem?

Thanks

Nonameman

Edited by Guest
Link to comment
That's because there's no player element on the chat box function also when you hit any client marker at you're server you'll get this message .

Sorry, code was wrong, the script is server-side, edited it, but still not working. Only triggers when the first hit happens.

Edited by Guest
Link to comment
  
local houses = {} 
local nextHouse = 0 
  
function createHouse ( player, commandName, name ) 
   local x, y, z = getElementPosition ( player ) 
   z = z - 1 
   local hMarker = createMarker ( x, y, z, "cylinder", 1.0 ) 
    
   if not name then 
        name = "House #" .. nextHouse 
   end 
    
   if hMarker then 
       houses[nextHouse] = {}     
       houses[nextHouse].marker = hMarker 
       houses[nextHouse].name = name 
       outputChatBox ( "House has been created!", player ) 
       nextHouse = nextHouse + 1 
   else 
       outputChatBox ( "House can't be created!", player ) 
   end 
end 
  
addCommandHandler ( "chouse", createHouse, false ) 
  
... 
  
-- And the previously written code 
  

SOLVED: Marker was too small.. -.-"

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