PDA

View Full Version : Triggeraction Problems


cbk1994
02-24-2007, 05:32 PM
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)

triggeraction( this.x +.5, this.y +.5, "BuyWep", [...] );


Here's the serverside onAction thing

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
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
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:


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
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
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
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

function onActionBuyWep()
{
player.chat = "trigger2";
}
//#CLIENTSIDE
function onCreated()
{
setshape( 1, 32, 32 );
setimg( this.image );
setTimer( 0.05 );
}
function onActionMouseClick()
{
showGui();
client.shopid = this.id;
}
function onMouseDown( button )
{
if ( button == "left" )
{
triggeraction( mousex, mousey, "MouseClick", player.account );
}
}
function onTimeOut()
{
chat = this.stockamm;
if ( this.stock == true )
{
this.stockamm = makevar( this.stockvar );
}
setTimer( 0.05 );
}
function showGUI()
{
// GUI is here, works fine
}

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


The local NPC that joins it ...

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
Shapes must be set on serverside.

Thanks :) That worked