GrainHHH Posted July 10, 2019 Share Posted July 10, 2019 (edited) 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? createMarker(2, 0, 2.22, "cylinder", 1.0, 255, 100, 100, 100) function toSpawnIt(player) spawnPlayer(player, 10, 0, 5) createMarker(12, 0, 2.22, "cylinder", 1.0, 255, 100, 100, 100) end addEventHandler("onMarkerHit", resourceRoot, toSpawnIt) thank you in advance! Edited July 10, 2019 by GrainHHH Link to comment
Moderators IIYAMA Posted July 10, 2019 Moderators Share Posted July 10, 2019 (edited) 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 July 10, 2019 by IIYAMA Link to comment
GrainHHH Posted July 10, 2019 Author Share Posted July 10, 2019 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 IIYAMA Posted July 10, 2019 Moderators Share Posted July 10, 2019 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
savour Posted July 11, 2019 Share Posted July 11, 2019 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
DNL291 Posted July 11, 2019 Share Posted July 11, 2019 If the player is already spawned use setElementPosition instead. 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