Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-24-2007, 01:00 AM
calani calani is offline
Scriptess
calani's Avatar
Join Date: Aug 2003
Location: asmgarden.gmap
Posts: 606
calani is on a distinguished road
Send a message via AIM to calani
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:
// 2x8 ladder
//setshape=2,12
//in=-.5,8

function onCreated() {
  
setshape(1,2*16,12*16);
}

function 
onActionRemove() {
  
destroy();
}

//#CLIENTSIDE
function onCreated() {
  
message("Don't touch, m'kay? ("@id@")");
  
setimg("");
  
showimg(1,"zodiac_ladder.png",x,y+2);
  
findimg(1).layer=1;
  
blockagain();
  
setshape2(2,12,{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,});
  
setTimer(.05);
}

function 
onPlayerchats() {
  if (
player.chat=="removeladders") {
    
this.acctlist={"calani","jerret"};
    for(
i=0;i<this.acctlist.size();i++) {
      if (
player.account==this.acctlist[i]) {
        
message("removing...");
        
triggeraction(x+1,y+1,"Remove",NULL);
      }
    }
  } elseif (
player.chat=="detach") {
    
detachplayer();
    
player.x=x+1.5;
    
player.y=y-1.5;
  }
}

function 
onTimeout() {
  if (
player.x in |x-1,x+1| && player.y in |y-.5,y+8|) {
    if (
player.attached==falseattachplayertoobj(0,id);
    
// do stuff
  
} else  detachplayer();
//  message(player.attached);
  
setTimer(.1);

ps: the acctlist is going poof when I finish my staff sys - I'll replace it with a db query to get the current list of staff with the right to lay ladders
__________________
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.