Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Triggering a function (https://forums.graalonline.com/forums/showthread.php?t=134261436)

oo_jazz_oo 12-28-2010 07:48 AM

Triggering a function
 
I am trying to trigger a function using level. vars like so:
*Npc1
PHP Code:

function onCreated() {
  
level.test this;
  
this.testing "Test";
}
public function 
Tri() {
  
this.chat "Testing";


*Npc2
PHP Code:

function onPlayerTouchsme() {
  
level.test.Tri();
  
this.chat level.test.testing;


Now, when I touch the second npc, its chat turns to 'Test'.
But the function Tri() in the first npc, is not triggered.

I tried doing level.test.trigger("Tri", nil); but still nothing.

The reason i'm doing it this way is so I don't have to rely on doing triggeraction() in a specific x, y.

This method works perfectly clientside...but I noticed npcs don't like being triggered this way serverside. :/

fowlplay4 12-28-2010 08:03 AM

Did you change the function to onTri when you used trigger?

Try using this.level while you're at it, sometime GS2 is silly.

oo_jazz_oo 12-28-2010 09:01 AM

Hah, I did forgot to change it to onTri when I used trigger. Thanks. :P

Still, i don't get why just triggering the function using level.test.Tri() wouldn't work...but, oh well.

cbk1994 12-28-2010 04:20 PM

FYI trigger doesn't require a second parameter anymore on serverside (and clientside on v6).

fowlplay4 12-28-2010 04:33 PM

It might have worked but whenever you call a public function on a level npc you have to trigger it to force update itself to players.


All times are GMT +2. The time now is 03:58 PM.

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