Jump to content

[ 5 lines ] eteral spawn after hitting the marker


GrainHHH

Recommended Posts

The script should create first marker in that position [2, 0, 2.22]

After i hit the marker, script should create second marker in that position[12, 0, 2.22]

And that's it, nothing more but look at the screen

Istead of just creating second marker when i hit first, script start as i understand create it over and over again but WHY?

And how can i fix that problem?

  1. createMarker(2, 0, 2.22, "cylinder", 1.0, 255, 100, 100, 100)
  2. function toSpawnIt(player)
  3.     spawnPlayer(player, 10, 0, 5)
  4.     createMarker(12, 0, 2.22, "cylinder", 1.0, 255, 100, 100, 100)
  5.     
  6. end
  7. addEventHandler("onMarkerHit", resourceRoot, toSpawnIt)
     

thank you in advance!

wtf.png

Edited by GrainHHH
Link to comment
  • Moderators
local firstMarker = createMarker(2, 0, 2.22, "cylinder", 1.0, 255, 100, 100, 100) 



addEventHandler("onMarkerHit", firstMarker, toSpawnIt)

 

Hmm, aren't you teleporting yourself into your just created marker?

If yes. Which  teleports again in 2 markers, which then teleports you in 3 markers and then it teleports you in 4 markers, (not even a frame as been past by), markers: 5, 6, 100, 1000, 10000000 ... ???

 

@GrainHHH

 

Edited by IIYAMA
Link to comment
14 minutes ago, IIYAMA said:

local firstMarker = createMarker(2, 0, 2.22, "cylinder", 1.0, 255, 100, 100, 100) 



addEventHandler("onMarkerHit", firstMarker, toSpawnIt)

 

Hmm, aren't you teleporting yourself into your just created marker?

If yes. Which  teleports again in 2 markers, which then teleports you in 3 markers and then it teleports you in 4 markers, (not even a frame as been past by), markers: 5, 6, 100, 1000, 10000000 ... ???

 

@GrainHHH

 

i thought about it but look

1. I create FIRST  marker here [2, 0, 2.22]

2. When i teleport myself here [10, 0, 5]

3.  And create SECOND marker here [12, 0, 2.22,]

I don't place myself in new created marker.

Maybe i should add delay in between teleporting myself and creating third marker?

I think the game just doesnt't have enough time to spawn me in new place before createing new marker.

Definetely will try it out

Link to comment
  • Moderators
4 hours ago, GrainHHH said:

Maybe i should add delay in between teleporting myself and creating third marker?

Nah, if you do not spawn yourself in to the (new) marker then there shouldn't be a reason for this kind of overflow behaviours.

Are you 100% sure these 5 lines are responsible or are there more?

 

Anyway, there is some strange error in the console that makes no sense:

Expected player at argument 1, got marker.

It is almost as if your new created marker triggers the event by colliding with the other marker. Which is kinda ...

How about you move the new created marker at a very different location?

Link to comment

The thing is, marker hits are triggered for a lot of elements (including other markers as well), not just players, so you have to specify that.

local respawnMarker = createMarker(2, 0, 2.22, "cylinder", 1.0, 255, 100, 100, 100)
function toSpawnIt(player)
  if source == respawnMarker and getElementType(player) == "player" then
    spawnPlayer(player, 10, 0, 5)
  end
end
addEventHandler("onMarkerHit", resourceRoot, toSpawnIt)
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...