![]() |
fun with ladders and attachplayertoobj(). well, not really.
People have done this before.
I just can't figure out how they managed it, and its rather annoying. Anyway, here's my dilemma: I have a ladder class that attaches players to it when they get nearby (inside x-1..x+1 and y-.5..y+8) and lets them move on the ladder until they go past one of the ends, then it detaches them. This works perfectly. However, when I lay a second ladder, the first stops attaching, but the second works just fine. If I lay a third, that one works fine, but the second one stops working. I'm using attachplayertoobj(0,id) so I'm not sure why it only works for the most-recently layed ladder. Bugging the crap out of me, too. Anyway, here's the class: PHP Code:
|
Hmm, whenever you place a new one, is 'id' always different? ( referring to message("Don't touch, m'kay? ("@id@")"); )
Also, is it a joined class, like join("ladder"); in a level, or putnpc2? |
yes, they are always different.
and by layed class I mean a putnpc2(). |
This causes the last created ladder to unattach the player all the time since he/she isnt close to the ladder.
PHP Code:
PHP Code:
|
Thanks to ziro, its fixed =)
Script ladder updated by xXziroXx (x12 or so) Ladder Solution Guy: Fixed. DND: oO how? Ladder Solution Guy: if (player.x in |x-1,x+1| && player.y in |y-.5,y+8|) { ... } else detachplayer(); Ladder Solution Guy: changed to Ladder Solution Guy: if (player.x in |x-1,x+1| && player.y in |y-.5,y+8|) { ... } else if (player.attached == true) detachplayer(); Ladder Solution Guy: since other wise the last created ladded will unattach the player since he/she isnt close to the ladded Ladder Solution Guy: ladder* and for those that just want to look at the fixed version: PHP Code:
Drat, you beat me to it! |
The wiki says this
NPC Code: So I think it will attach it to the current npc (the last layed npc) :o hmm, but that shouldn't effect that.. |
Quote:
|
Quote:
|
Hmmm I would say you should add one more check:
if (player.attachedtoobject==this) detachplayer(); or if (player.attachid==id) detachplayer(); otherwise the ladders might detach the player from other ladders |
Quote:
|
much better.
*adds* |
| All times are GMT +2. The time now is 05:50 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.