RandomRambo Posted August 8, 2021 Share Posted August 8, 2021 Hello guys. Is it real to make this thing. If someone moved on marker,is it possible to not let another player move to this marker (he needs to wait SOME TIME for example). (Marker teleports player to some place btw) Link to comment
βurak Posted August 8, 2021 Share Posted August 8, 2021 (edited) yes it is possible getTickCount maybe will work for you? example: local DELAY_TELEPORT = 5000 -- millisecond delay local IntervalTeleport = 0 local teleportMarker = createMarker(0, 0, 3, "cylinder", 3.0, 255, 0, 0, 255) addEventHandler("onMarkerHit", teleportMarker, function(hitElement) if(getElementType(hitElement) == "player") then if(IntervalTeleport and getTickCount() - IntervalTeleport > DELAY_TELEPORT) then --teleport player every 5 second setElementPosition(hitElement, 106.99030, 1924.18860, 18.52914) IntervalTeleport = getTickCount() else outputChatBox("You need to wait 5 seconds!", hitElement, 255, 0, 0, false) end end end ) Edited August 8, 2021 by Burak5312 Link to comment
RandomRambo Posted October 12, 2021 Author Share Posted October 12, 2021 On 08/08/2021 at 08:18, Burak5312 said: yes it is possible getTickCount maybe will work for you? example: local DELAY_TELEPORT = 5000 -- millisecond delay local IntervalTeleport = 0 local teleportMarker = createMarker(0, 0, 3, "cylinder", 3.0, 255, 0, 0, 255) addEventHandler("onMarkerHit", teleportMarker, function(hitElement) if(getElementType(hitElement) == "player") then if(IntervalTeleport and getTickCount() - IntervalTeleport > DELAY_TELEPORT) then --teleport player every 5 second setElementPosition(hitElement, 106.99030, 1924.18860, 18.52914) IntervalTeleport = getTickCount() else outputChatBox("You need to wait 5 seconds!", hitElement, 255, 0, 0, false) end end end ) Thanks,but how can I do that may be after 5 guys hit the marker it will be closed like this?(not 1 like now) Link to comment
kewizzle Posted October 12, 2021 Share Posted October 12, 2021 (edited) marker = createMarker(arguments) setElementData(marker, "playerhit", 5) function markerData() getplayerhit = getElementData(marker, "playerhit") if getplayerhit >= 1 then setElementPosition( arguments ) setElementData(marker, "playerhit" getplayerhit-1) elseif getplayerhit == 0 then outputChatBox("You need to wait some time to enter this", thePlayer, 255, 0, 0) end end addEventHandler("onMarkerHit", marker, markerData) --make a timer function that sets the element data of the marker back to 5 for "playerhit". yes you will get errors if you straight up use this code read through it and add your arguments to what you want use setTimer for the timer function. Edited October 12, 2021 by kewizzle Link to comment
βurak Posted October 13, 2021 Share Posted October 13, 2021 On 12/10/2021 at 07:37, RandomRambo said: Thanks,but how can I do that may be after 5 guys hit the marker it will be closed like this?(not 1 like now) local DELAY_TELEPORT = 5000 -- millisecond delay local IntervalTeleport = 0 local hitsCount = 0 local teleportMarker = createMarker(0, 0, 3, "cylinder", 3.0, 255, 0, 0, 255) addEventHandler("onMarkerHit", teleportMarker, function(hitElement) if(getElementType(hitElement) == "player") then if(hitsCount < 5) then setElementPosition(hitElement, 106.99030, 1924.18860, 18.52914) hitsCount = hitsCount + 1 else if(IntervalTeleport and getTickCount() - IntervalTeleport > DELAY_TELEPORT) then --teleport player every 5 second setElementPosition(hitElement, 106.99030, 1924.18860, 18.52914) IntervalTeleport = getTickCount() else outputChatBox("You need to wait 5 seconds!", hitElement, 255, 0, 0, false) end end end end ) you can try this 1 Link to comment
RandomRambo Posted October 13, 2021 Author Share Posted October 13, 2021 7 hours ago, Burak5312 said: local DELAY_TELEPORT = 5000 -- millisecond delay local IntervalTeleport = 0 local hitsCount = 0 local teleportMarker = createMarker(0, 0, 3, "cylinder", 3.0, 255, 0, 0, 255) addEventHandler("onMarkerHit", teleportMarker, function(hitElement) if(getElementType(hitElement) == "player") then if(hitsCount < 5) then setElementPosition(hitElement, 106.99030, 1924.18860, 18.52914) hitsCount = hitsCount + 1 else if(IntervalTeleport and getTickCount() - IntervalTeleport > DELAY_TELEPORT) then --teleport player every 5 second setElementPosition(hitElement, 106.99030, 1924.18860, 18.52914) IntervalTeleport = getTickCount() else outputChatBox("You need to wait 5 seconds!", hitElement, 255, 0, 0, false) end end end end ) you can try this Thanks,I'll try! 1 Link to comment
RandomRambo Posted October 14, 2021 Author Share Posted October 14, 2021 On 13/10/2021 at 15:30, Burak5312 said: local DELAY_TELEPORT = 5000 -- millisecond delay local IntervalTeleport = 0 local hitsCount = 0 local teleportMarker = createMarker(0, 0, 3, "cylinder", 3.0, 255, 0, 0, 255) addEventHandler("onMarkerHit", teleportMarker, function(hitElement) if(getElementType(hitElement) == "player") then if(hitsCount < 5) then setElementPosition(hitElement, 106.99030, 1924.18860, 18.52914) hitsCount = hitsCount + 1 else if(IntervalTeleport and getTickCount() - IntervalTeleport > DELAY_TELEPORT) then --teleport player every 5 second setElementPosition(hitElement, 106.99030, 1924.18860, 18.52914) IntervalTeleport = getTickCount() else outputChatBox("You need to wait 5 seconds!", hitElement, 255, 0, 0, false) end end end end ) you can try this Doesn't work It lets people to hit marker unlimited times anyway Link to comment
βurak Posted October 14, 2021 Share Posted October 14, 2021 20 minutes ago, RandomRambo said: Doesn't work It lets people to hit marker unlimited times anyway I tested the code, I didn't see any problems, it works as it should, maybe you can extend the waiting delay? Link to comment
RandomRambo Posted October 14, 2021 Author Share Posted October 14, 2021 Just now, Burak5312 said: I tested the code, I didn't see any problems, it works as it should, maybe you can extend the waiting delay? ye I put 30 mins delay And when i hit 5 times marker,on the sixth try it let me hit it again Link to comment
βurak Posted October 14, 2021 Share Posted October 14, 2021 4 minutes ago, RandomRambo said: ye I put 30 mins delay And when i hit 5 times marker,on the sixth try it let me hit it again ok my mistake try this code local DELAY_TELEPORT = 5000 -- millisecond delay local IntervalTeleport = 0 local hitsCount = 0 local teleportX, teleportY, teleportZ = 106.99030, 1924.18860, 18.52914 local teleportMarker = createMarker(0, 0, 3, "cylinder", 3.0, 255, 0, 0, 255) addEventHandler("onMarkerHit", teleportMarker, function(hitElement) if(getElementType(hitElement) == "player") then if(hitsCount < 5) then setElementPosition(hitElement, teleportX, teleportY, teleportZ) hitsCount = hitsCount + 1 if(hitsCount == 5) then IntervalTeleport = getTickCount() end else if(IntervalTeleport and getTickCount() - IntervalTeleport > DELAY_TELEPORT) then --teleport player every 5 second setElementPosition(hitElement, teleportX, teleportY, teleportZ) IntervalTeleport = getTickCount() else outputChatBox("You need to wait 5 seconds!", hitElement, 255, 0, 0, false) end end end end ) 1 Link to comment
RandomRambo Posted October 14, 2021 Author Share Posted October 14, 2021 8 minutes ago, Burak5312 said: ok my mistake try this code local DELAY_TELEPORT = 5000 -- millisecond delay local IntervalTeleport = 0 local hitsCount = 0 local teleportX, teleportY, teleportZ = 106.99030, 1924.18860, 18.52914 local teleportMarker = createMarker(0, 0, 3, "cylinder", 3.0, 255, 0, 0, 255) addEventHandler("onMarkerHit", teleportMarker, function(hitElement) if(getElementType(hitElement) == "player") then if(hitsCount < 5) then setElementPosition(hitElement, teleportX, teleportY, teleportZ) hitsCount = hitsCount + 1 if(hitsCount == 5) then IntervalTeleport = getTickCount() end else if(IntervalTeleport and getTickCount() - IntervalTeleport > DELAY_TELEPORT) then --teleport player every 5 second setElementPosition(hitElement, teleportX, teleportY, teleportZ) IntervalTeleport = getTickCount() else outputChatBox("You need to wait 5 seconds!", hitElement, 255, 0, 0, false) end end end end ) Now it works perfectly!Thanks a lot 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now