View Single Post
  #7  
Old 02-12-2009, 04:35 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Loriel View Post
I think what Tyhm is looking for here is triggering the "other" side of the script without involving coordinates or the chance that other scripts might be hit by it.
If you have an NPC's ID and level name, you can send it to a triggerserver/client and simply use functions to locate the NPC object.

These are two functions extracted from my triggercontrol class that is used to wrap the triggerserver() and triggerclient() in weapons:
PHP Code:
public function npcfunction(lvlnamenpcidfuncnamep3p4p5p6p7p8p9) {
  for (
temp.ifindlevel(temp.lvlname).npcs) {
    if (
temp.i.id == temp.npcid) {
      return 
temp.i.(@ temp.funcname)(temp.p3temp.p4temp.p5temp.p6temp.p7temp.p8temp.p9);
    }
  }
}
//#CLIENTSIDE
public function npcfunction(npcidfuncnamep2p3p4p5p6p7p8p9) {
  return 
findnpcbyid(temp.npcid).(@ temp.funcname)(temp.p2temp.p3temp.p4temp.p5temp.p6temp.p7temp.p8temp.p9);

Call clientside part of an NPC from serverside, assuming I have a calling player, I can:

WeaponName.ClientFunction(null, "npcfunction", this.id, "saystuff", "lol I like pancakes");

Or from the client:

WeaponName.ServerFunction(null, "npcfunction", this.level.name, this.id, "saystuff", "Inverness was here");


Note that ClientFunction() and ServerFunction() are part of my class, they call a function on the other side and wait for return value. Naturally, I would prefer a hard-coded function, as it would be more efficient.
__________________
Reply With Quote