Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-02-2013, 11:44 AM
Pandar Pandar is offline
Babylon Co-Manager
Pandar's Avatar
Join Date: Jan 2007
Location: New York
Posts: 68
Pandar has a spectacular aura aboutPandar has a spectacular aura about
Triggerserver In a Level NPC

I'm not honestly sure how many people care about this at this point, especially when setshape & triggeraction has been such a viable option for a long time now, but I've actually come up with a solution to make this possible that I've personally tested and succeeded with. It's not efficient, but it does get the job done, and if you desperately need a local npc to use client/server interaction without having the npc have a shape, you can use this.

Anyway. First I'll explain the problem that actually causes this to initially not work. The issue is that level npcs simply do not have a name on the clientside of things. Only server. So the issue is that, basically, if you try to use

PHP Code:
triggerserver("npc"this.name"test"); 
you're telling it to trigger to nothing. Now, you'd think "oh I can just get the serverside name," but then comes the issue, if I can't trigger between serverside and clientside, how am I going to get that name? Well it's pretty obvious and easy. Maybe I'm not the first to figure this out, but in case anyone was interested, here you go.

PHP Code:
function onCreated() {
  
setTimer(1);
}

function 
onTimeOut() {
  for (
i:allplayers) {
    if (
i.level == this.level) {
      
i.client.lnpcn this.name;
    }
  }
  
setTimer(1);
}

function 
onActionServerside(f) {
  switch (
f) {
    case 
"f":
      
sendtorc("Pandar is ****ing rad as ****");
      break;
  }
}

//#CLIENTSIDE
function onCreated() { setTimer(1); }

function 
onTimeOut() {
  
this.client.lnpcn;
  
setTimer(1);
}

function 
WhatThe****EverYouWantToTriggerFrom() {
  
triggerserver("npc"this.n"f");

Basically what this does is repeatedly assign everybody in the level a client. flag of the serverside npc name. The npc can then run a constant loop that sets a variable to the serverside name by accessing each player's client flag, and using that to trigger.

Like I said, not sure if this serves anybody any use, but I was ****ing around this morning experimenting different methods of getting triggerserver to work in a Class NPC because I've always wanted to do it, (mostly because of my irrational hatred of triggeraction() ) and when I figured it out I thought I'd share with this lovely (read: vile) community. Also,

pls rep me.

Enjoy.
__________________
R.I.P. Graal (1998 - 2004)
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 06:18 AM.


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