Thread: phones!
View Single Post
  #1  
Old 07-06-2008, 09:43 AM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
phones!

so i am re-making payphones on Era, it all works fine [kinda]. The two phones connect to each other, but the text on the phone i am calling doesn't change, i've debugged it and it changes all the flags to what they need to be [even changes the 'c'] yet the text refuses to change.

HTML Code:
function onCreated() {
  this.setImg("phone_booth-1.gif");
  this.setShape(1, 32, 64);
  this.drawunderplayer();  
  
  this.phonestatus = "idle";
  this.linebusy = this.incomingcall = this.callingphone = false;
  this.updateChat();
}

public function updateChat() {
  temp.c = "";
  if (!this.number) c = "Awaiting Registration";
  elseif (this.number) c = this.number;
  if (this.linebusy) c = this.dialnum SPC "Busy";
  if (this.callingphone) c = "Calling" SPC this.dialnum;
  if (this.incomingcall) c = "Caller" SPC this.dialnum;

  this.chat = "(Eracom:" SPC c @ ")";
}

function onPlayerChats() {
  if (player.chat == "reset") this.onCreated();
}

function onActionGrab() {
  if (!this.number) {
    if (!player.chat.starts(":")) return false;   
    if (player.clientr.staff < 3) return false; 

    temp.chat = player.chat.substring(1);
    temp.tok = chat.tokenize();
    
    DB_PayPhones.trigger("AddPhone", this.name, tok[0], chat.substring(tok[0].length() + 1));
    return true;
  }  
  
  if (this.incomingcall) {
    this.acceptCall();
    return true;
  }
 
  if (player.chat == null) return false;
  if (player.chat == this.number) return false;
  
  if (player.chat in DB_PayPhones.numbers) {
    temp.npc = DB_PayPhones.("p_" @ player.chat);
    this.cphone = findNPC(npc[0]);
   
    this.dialnum = player.chat;
    
    switch(this.cphone.getStatus()) {
      case "idle": this.sendCall(); break;
      case "busy": this.linebusy = true; break;
    }
    
    this.owner = player;
    this.updateChat();
  } 
}

public function getStatus() {
  return this.phonestatus;
}

public function sendCall() {
  this.cphone.trigger("IncomingCall", this.name);
  this.phonestatus = "busy";
  this.callingphone = true;
}  

public function onIncomingCall(temp.npc) {
  this.phonestatus = "busy";
  this.incomingcall = true;
  this.cphone = findNPC(npc);

  this.updateChat();
  //This is the problem... I've tried everything
}

public function acceptCall() {
  this.owner = player;
  this.cPhone.trigger("StartCall", "");
  this.chat = "(Call Established)" SPC this.cPhone;
  //However, once I grab it this part works....
}

public function onStartCall() {
  this.chat = "Call's created between" SPC this.cPhone;
}
  
public function assignNumber(temp.num, temp.desc) {
  this.number = num;
  this.description = desc;
  this.updateChat();
}

function onActionStaffStick() {
  this.DestroyPhone();
}

public function DestroyPhone() {
  DB_PayPhones.trigger("DestroyPhone", this.number, this.description);
  this.destroy();
}

//#CLIENTSIDE
function onCreated() {
  setshape2(2, 3, {
    22, 22,
    22, 22,
    22, 22
  });
}
Reply With Quote