Search the Community
Showing results for tags 'server event'.
-
Hey everyone, again, I have a problem. I want to teleport the player whenever it hits the entry/exit marker of a Burger Shot. However, whenever I add the functions to the "onMarkerHit" event, I keep teleporting back and forth. Script is server-sided. --Entry/Exit marker grabbed from .map file local burgershotEnter = getElementByID("burgershotEnter") local burgershotExit = getElementByID("burgershotExit") -- Table of spawn location when entering/leaving Burger Shot local burgershotSpawn = { enter = { x = 364.4189453125, y = -74.154296875, z = 1001.5078125, rot = 313.42001342773 }, exit = { x = -2334.7392578125, y = -166.7958984375, z = 35.5546875, rot = 221.95193481445 } } -- Debug stuff whether coordinates of entry/exit markers are the same as defined in .map (which in this case, it is) local enterPosX, enterPosY, enterPosZ = getElementPosition(burgershotEnter) local exitPosX, exitPosY, exitPosZ = getElementPosition(burgershotExit) outputChatBox ( "Enter: " .. tostring(burgershotEnter) .. " " .. enterPosX .. ", " .. enterPosY .. ", " .. enterPosZ ) outputChatBox ( "Exit: " .. tostring(burgershotExit) .. " " .. exitPosX .. ", " .. exitPosY .. ", " .. exitPosZ ) --------------------------------------- function burgershotEnterHit( player ) outputChatBox("Welcome to Burger Shot! If you want to order something, click on the ped.") setElementInterior( player, 10, burgershotSpawn["enter"]["x"], burgershotSpawn["enter"]["y"], burgershotSpawn["enter"]["z"]) --setPlayerRotation( burgershotSpawn["enter"]["rot"] ) end function burgershotExitHit( player ) outputChatBox("Thanks for visiting Burger Shot! Come again soon!") setElementInterior( player, 0, burgershotSpawn["exit"]["x"], burgershotSpawn["exit"]["y"], burgershotSpawn["exit"]["z"]) --setPlayerRotation( burgershotSpawn["exit"]["rot"] ) end addEventHandler( "onMarkerHit", burgershotEnter, burgershotEnterHit ) addEventHandler( "onMarkerHit", burgershotExit, burgershotExitHit ) Do I still have to check if the player is in the marker or not? Because I thought I don't need to do that when I tie the function to an event with the according marker. Thanks in advance!