Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   triggeraction x y and putnpc2 x y (https://forums.graalonline.com/forums/showthread.php?t=55049)

prozac424242 08-24-2004 10:09 PM

triggeraction x y and putnpc2 x y
 
I am trying to get a clientside triggeraction to place an npc serverside:

My question is, how do I access the x and y, sent from the triggeraction, on the server, in the putnpc2 command?

Here is the clientside part
NPC Code:


if (actionplant)
{
putnpc2 x,y,
{
setimage ion.gif;
message I am an ion;
}
}


#//CLIENTSIDE
if (weaponfired)
{
//set animation or sprite
freezeplayer .1;
playersprite=33;
// perform an action in front of the player
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,
plant,;
}



Any help would be appreciated.

vahn32 08-24-2004 10:16 PM

Ok, first of all it's not #//CLIENTSIDE, it's //#CLIENTSIDE.
Second of all you need to trigger the weapon itself to run a script in it serverside.
Example:
NPC Code:
if (actionserverside) {
//stuff here
}
//#CLIENTSIDE
if (weaponfired) {
triggeraction 0,0,serverside,WEAPONNAME,params;
}


To access any params sent from a triggeraction, use #p(0-#)
They are strings, so you convert them to integers for use in X and Y placements, use strtofloat(#p(#0));
Then again I haven't scripted in awhile but I think that's everything you need to know.
[Edit]Edited because I think I was under the influence of fatigue while typing.

Lance 08-24-2004 10:17 PM

  • //#CLIENTSIDE
  • Weapon triggeractions take the form:
    triggeraction 0,0,serverside,weaponname,params;
  • They are received with the if (actionserverside) event, it is usually good to assign a name to the first parameter (and then check it on the serverside part) so it is easy to add other triggeractions to it later

Quote:

Originally Posted by vahn32
Example:
NPC Code:
if (actiondoop) {
//stuff here
}
//#CLIENTSIDE
if (weaponfired) {
triggeraction 0,0,serverside,WEAPONNAME,params;
}


Refer to bullet 3

prozac424242 08-24-2004 11:39 PM

Still does not put the npc on my server,
I tried putting in other ways to tell if the npc was created

NPC Code:

/////////////////////////////
//action of this npc = plant (for farming)
/////////////////////////////

if (actionplant)
{
putexplosion 1,x,y;
putnpc2 30,30,{
setimg ion.gif;
setplayerprop #c, I am an ion;
shootarrow up;
}
}

//#CLIENTSIDE

if (weaponfired && isweapon)
{
//set animation or sprite
freezeplayer .1;
playersprite=33;

triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,plant,Planting,;

}





Why does this still not work?

xManiamaNx 08-24-2004 11:49 PM

IF i understand this right, that is all in the same NPC.

Since you have:
NPC Code:
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe  rdir)*2,pl  ant,Planting,;



the (actionplant) stuff needs to be in another NPC.

prozac424242 08-25-2004 12:00 AM

(missing the days of graal 1.28 when I understood npcs)

Why does it need to be in another npc?

Does anyone have a working example to share
that uses triggeractoin to perform a putnpc2 ccommand?

falco10291029 08-25-2004 12:17 AM

I can do something with triggeraction and a putnpc2


NPC Code:

if (actionserverside) {

putnpc2 strtofloat(#p(0)),strtofloat(#p(1)),{

//stuff happens here ;)

}



}


//#CLIENTSIDE
if (weaponfired) {
triggeraction 0,0,serverside,weponname,#v(playerx+vecx(playerdir )*2+1.5),#v(playery+2+vecy(playerdir)*2);
}





There I didn't check over it so there may be spelling errors but that should do the trick.

prozac424242 08-25-2004 01:12 AM

THanks, I got it to work!

Interesting that the first two paramaters have to be 0.

falco10291029 08-25-2004 03:05 AM

Yeh well when u trigger something serverside u do 0,0 so it hits the npc server

xManiamaNx 08-25-2004 05:00 AM

Quote:

Originally Posted by prozac424242
Why does it need to be in another npc?

Because of the way you were using the triggeraction.

Quote:

Originally Posted by falco34896732947823insertrandomnumbershere34875234 49057239
Yeh well when u trigger something serverside u do 0,0 so it hits the npc server

I doubt this is a valid statement.

GoZelda 08-25-2004 01:37 PM

Quote:

Originally Posted by Lance
  • Weapon triggeractions take the form:
    triggeraction 0,0,serverside,weaponname,params;

Is this automatically set, or is this some sort of 'agreement' between scripters?

osrs 08-25-2004 03:07 PM

If you read newfeatures, there is a way to use triggeraction from server-side to client-side on weapons, if you did not know, here is what is written and may help you.

Quote:

- server-side scripts can do
'triggeraction 0,0,clientside,weapon,params'
to directly trigger the client-side part of
weapon of the player - catch it with
'if (actionclientside) actions;'

ZeroTrack 08-25-2004 03:08 PM

I believe its automatically set , esp sence GScript is a 3rd party scripting engine

~Sern

falco10291029 08-25-2004 03:34 PM

Yeah well i knew my statement wasnt the actual reason it just made me feel better since it basically made sense

GoZelda 08-25-2004 03:50 PM

Quote:

Originally Posted by osrs
If you read newfeatures, there is a way to use triggeraction from server-side to client-side on weapons, if you did not know, here is what is written and may help you.

Ah, comme ça. Thanks, yeah I read that part but I thought it was a weapon that did a serverside trigger...

Lance 08-25-2004 06:00 PM

Quote:

Originally Posted by prozac424242
THanks, I got it to work!

Interesting that the first two paramaters have to be 0.

They don't have to be - it just doesn't make sense to throw in (more) irrelevant, unused values.

In the new scripting engine, this is much simpler. :)

osrs 08-25-2004 06:05 PM

Quote:

Originally Posted by GoZelda
Ah, comme ça. Thanks, yeah I read that part but I thought it was a weapon that did a serverside trigger...

It can be done from the server-side part of a weapon too.

ZeroTrack 08-25-2004 08:01 PM

Easiest way to do it with putnpc2 is just join it with a class npc

Rick 08-25-2004 08:31 PM

Quote:

Originally Posted by ZeroTrack
I believe its automatically set , esp sence GScript is a 3rd party scripting engine

~Sern

How is it third party?

ZeroTrack 08-25-2004 10:56 PM

Quote:

Originally Posted by Rick
How is it third party?

I believe it uses delphi or C to covert the engine

falco10291029 08-25-2004 11:20 PM

yeah gscript is based on a different scripting language and has builtin commands that basically makes it 3rd party

Rick 08-26-2004 01:49 AM

Wrong expression/words for that context.

falco10291029 08-26-2004 03:04 AM

hows that?

Rick 08-26-2004 06:33 AM

Third party means that it was developed outside of the team/company that made the original product.

Such as Graal User Statistics (Graal.us) is third party software for GraalOnline.

falco10291029 08-26-2004 05:00 PM

Oh I'm probably thinking of some other word that has the definition that i said but het cant blame me for my stupidity!

GoZelda 08-26-2004 07:13 PM

Quote:

Originally Posted by falco10291029
Oh I'm probably thinking of some other word that has the definition that i said but het cant blame me for my stupidity!

No, neither can you blame those that crashed into Twin Towers :rolleyes:


All times are GMT +2. The time now is 07:11 PM.

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