PDA

View Full Version : triggeractions in classes


coreys
10-27-2006, 02:50 AM
On Uprising we are using a class for dropped items. It's joined with putnpc2. But, we need to use triggeraction, but we can't get them to work the way you use them in weapons. Can anyone tell me how to use triggeractions in classes joined to npcs layed with putnpc2? Oh, and in normal NPCs as well.

Admins
10-27-2006, 04:02 AM
There shouldn't be differences to normal npc scripts. What exactly do you try to do with the trigger?

coreys
10-27-2006, 05:00 AM
Well, the person who was doing it was trying to get it to trigger to serverside to destroy when the player clicked on it. Of course, then I realized the onActionLeftMouse() worked serverside. lol

xAndrewx
10-27-2006, 08:03 AM
Haha, that's correct =]

Gambet
10-27-2006, 12:32 PM
On Uprising we are using a class for dropped items. It's joined with putnpc2. But, we need to use triggeraction, but we can't get them to work the way you use them in weapons. Can anyone tell me how to use triggeractions in classes joined to npcs layed with putnpc2? Oh, and in normal NPCs as well.



For future reference, you trigger to the serverside in class npcs the same you would in a level


triggeraction(setanx,setay,"action",params);



EXAMPLE:


function onActionTest() {
player.chat = "You just triggered! =)";
}

//#CLIENTSIDE
function onCreated {
triggeraction(x+0.5,y+0.5,"test","");
}



The format is different from the way it's set up for weapon npcs. Also take note that everything you put in the params will start with params[0] and not params[1].

fowlplay4
10-28-2006, 10:06 PM
function onCreated() {
setshape(1,32,32); // So the Trigger is Hits something Serverside.
}
function onActionTest() {
if (params[0] != id) this.chat = "Some other npc hit me :(" SPC params[0];
else this.chat = "that tickles" SPC params[1];
}
//#CLIENTSIDE
function onCreated() {
triggeraction(x+1,y+1,"test",id,"lol"); //sending trigger
}

coreys
11-28-2006, 02:06 AM
Well...I still haven't been able to get triggeractions in level npcs working. I've tried just about everything, including what you guys have mentioned.

Last thing I tried was this:
function onActionTrigger() {
switch(params[0]) {
case "init":
message("Active...");
break;
}
}
//#CLIENTSIDE
function onCreated() {
triggeraction(x,y,"Trigger","init");
}

Gambet
11-28-2006, 02:55 AM
You need to set a shape to the npc so that an object is set, and you need to specify an x and y when triggering in a level/class npc.


function onCreated() {
setshape(1,32,32);
}

function onActionTrigger() {
switch(params[0]) {
case "init":
message("Active..."); break;
}
}

//#CLIENTSIDE
function onCreated() {
triggeraction(x+1.5,y+1.5,"Trigger","init");
}

coreys
11-28-2006, 03:04 AM
Ah! Thank you very much. =0

xAndrewx
11-28-2006, 08:58 AM
I am not too sure, but I am pretty sure you can use triggerserver, I think I've seen it used before inside a class...

Make a new function that finds the NPC and also sends the action to the serverside
function onCreated()
{
this.tiggerServer(pars);
}
That basically finds the current NPC (findNPC()) and then do the actionServerside part!

Gambet
11-28-2006, 10:01 PM
I've never heard nor seen triggerserver being used in classes/level npcs, for I've always been under the impression that it is not possible. Why don't you test it out and report your results?

xAndrewx
11-29-2006, 09:14 AM
I've never heard nor seen triggerserver being used in classes/level npcs, for I've always been under the impression that it is not possible. Why don't you test it out and report your results?

No time, going away in like five hours :[
''http://forums.graalonline.com/forums/showthread.php?p=1248203#post1248203''