Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Triggeraction Problems (https://forums.graalonline.com/forums/showthread.php?t=72433)

cbk1994 02-24-2007 05:32 PM

Triggeraction Problems
 
I'm using a DB NPC, I need to trigger it from a class that the DB NPC is joined to.
The DB NPC's image is block.png

Here's the trigger (clientside)
PHP Code:

triggeractionthis.+.5this.+.5"BuyWep", [...] ); 

Here's the serverside onAction thing
PHP Code:

function onActionBuyWep( [...] )
{
  
player.chat "trigger2";
  [...]


What am I doing wrong?

Chompy 02-24-2007 05:43 PM

When using triggeraction() in a class, it will go serverside..
So when on serverside in the class, use findnpc()..
:)

cbk1994 02-24-2007 05:51 PM

Quote:

Originally Posted by Chompy (Post 1281611)
When using triggeraction() in a class, it will go serverside..
So when on serverside in the class, use findnpc()..
:)

Thanks for quick response, but what I'm really trying to figure out is how to do it with local NPCs. The DB NPC I made for a test (quick editing).
Basicly the local NPCs will have the exact same script ...

Gambet 02-24-2007 05:54 PM

Quote:

Originally Posted by cbkbud (Post 1281616)
Thanks for quick response, but what I'm really trying to figure out is how to do it with local NPCs. The DB NPC I made for a test (quick editing).
Basicly the local NPCs will have the exact same script ...


Have local NPCs join the class that is triggering to the DB NPC.

godofwarares 02-24-2007 05:54 PM

Use classes and join them in the Local NPC and use this code to trigger between the DB NPC and the class:

PHP Code:

triggerserver("npc""DBName""BuyItem", [...]); 


cbk1994 02-24-2007 05:57 PM

Let me try to explain ...
screw the DB NPC.
I have a local NPC that joins the shop item class.
The class does everything right, then it triggers, but it doesn't receive the trigger on serverside.

Chompy 02-24-2007 05:59 PM

Quote:

Originally Posted by cbkbud (Post 1281622)
Let me try to explain ...
screw the DB NPC.
I have a local NPC that joins the shop item class.
The class does everything right, then it triggers, but it doesn't receive the trigger on serverside.

The class do have a shape?
It needs a shape to recieve the trigger..

Gambet 02-24-2007 06:00 PM

Quote:

Originally Posted by cbkbud (Post 1281622)
Let me try to explain ...
screw the DB NPC.
I have a local NPC that joins the shop item class.
The class does everything right, then it triggers, but it doesn't receive the trigger on serverside.


Posting the code does help...

Chompy 02-24-2007 06:01 PM

Quote:

Originally Posted by Gambet (Post 1281626)
Posting the code does help...

I second that..

We have no idea if what you are doing serverside is correct or it does have a shape..

cbk1994 02-24-2007 06:09 PM

The class
PHP Code:

function onActionBuyWep()
{
  
player.chat "trigger2";
}
//#CLIENTSIDE
function onCreated()
{
  
setshape13232 );
  
setimgthis.image );
  
setTimer0.05 );
}
function 
onActionMouseClick()
{
  
showGui();
  
client.shopid this.id;
}
function 
onMouseDownbutton )
{
  if ( 
button == "left" )
  {
    
triggeractionmousexmousey"MouseClick"player.account );
  }
}
function 
onTimeOut()
{
  
chat this.stockamm;
  if ( 
this.stock == true )
  {
    
this.stockamm makevarthis.stockvar );
  }
  
setTimer0.05 );
}
function 
showGUI()
{
 
// GUI is here, works fine
}

function 
Shop_Buy.onAction()
{
  if ( 
client.shopid == this.id )
  {
    if ( 
player.rupees >= this.realprice )
    {
      
triggeractionthis.xthis.y"BuyWep");
    }
    else
    {
      
player.chat "You cannot afford this!";
    }
  }


The local NPC that joins it ...
PHP Code:

join"shoptest" );
//#CLIENTSIDE
function onCreated()
{
  
this.image "block.png";
  
this.weaponname "Items/Explosives";
  
this.itemname "Plastic Explosives";
  
this.itemprice 100;



Inverness 02-24-2007 06:09 PM

Set the shape of the NPC then trigger the action on itself.
Shape must be set on serverside.

cbk1994 02-24-2007 06:19 PM

Quote:

Originally Posted by Inverness (Post 1281630)
Shapes must be set on serverside.

Thanks :) That worked


All times are GMT +2. The time now is 08:12 AM.

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