Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   More fun with clientside and serverside (https://forums.graalonline.com/forums/showthread.php?t=61388)

Googi 09-25-2005 06:01 PM

More fun with clientside and serverside
 
Okay. So say I have an event and I want to do five things. Two are serverside, three are clientside. How do I do this? More realisticly, say I have sixteen events and want each to do 8 things, 4 serverside and 4 clientside. Is there a way to do it without running the script twice (once above the //#CLIENTSIDE and once below it)?

Skyld 09-25-2005 07:26 PM

Quote:

Originally Posted by Googi
Okay. So say I have an event and I want to do five things. Two are serverside, three are clientside. How do I do this? More realisticly, say I have sixteen events and want each to do 8 things, 4 serverside and 4 clientside. Is there a way to do it without running the script twice (once above the //#CLIENTSIDE and once below it)?

Well, you wouldn't want to run the same script on both clientside and serverside for the obvious reason - the clientside will do some things that the serverside won't and the serverside will do some things that the clientside won't. The NPC-Server won't exactly spit fire if you, say, try to use showimg on the serverside, but it's overall not recommended.

What you need to do is arrange your script so that the serverside and clientside can work together; that's if I've understood what you're trying to do properly, of course. For example, if you want to display pictures on the clientside that warp players when you click them, then you'll want to have the image display and the click detection on the clientside, and triggeraction to the serverside to warp the player.

If you're using a weapon, you can do the following (GScript2):
NPC Code:
function onActionserverside()
{
if (params[0] == "foo")
{
sendtonc("bar");
}
}
//#CLIENTSIDE
function onMouseDown()
{
triggeraction(0, 0, "serverside", "Weapon/Name", "foo");
}


Or GScript:
NPC Code:

if (actionserverside)
{
if (strequals(#p(0), foo))
{
sendtonc bar;
}
}
//#CLIENTSIDE
if (mousedown)
{
triggeraction 0, 0, serverside, Weapon/Name, foo;
}



In these examples, you would put the player warping (or whatever) on the serverside, and the detection of you clicking on the clientside.

If you're not using weapons, then you can still triggeraction to the serverside by triggeractioning on the NPC's coordiates instead of triggeractioning to (0,0).

I hope this is of some help.

Googi 09-29-2005 10:06 PM

I can just use the x and y variables to work as the NPCs x and y no matter where the NPC is, right?

And also, for triggeractioning to the serverside, you can only have one NPC in the entire level with that specific action event condition or else all NPCs with that action event condition will be triggered, right?

Skyld 09-29-2005 10:27 PM

Quote:

Originally Posted by Googi
I can just use the x and y variables to work as the NPCs x and y no matter where the NPC is, right?

Yes, but you must triggeraction onto the object, maybe a setshape surface.

Edit: May not be the same on GMAPs however. GMAP X and Ys are not always level X and Ys.
Quote:

Originally Posted by Googi
And also, for triggeractioning to the serverside, you can only have one NPC in the entire level with that specific action event condition or else all NPCs with that action event condition will be triggered, right?

Not quite. The action will only happen for NPCs on the triggered position, or for the specified weapon name.

Googi 09-30-2005 12:18 AM

I can trigger from the serverside to the clientside too, right?

ForgottenLegacy 09-30-2005 12:25 AM

Quote:

Originally Posted by Googi
I can trigger from the serverside to the clientside too, right?

Currently, only in weapons. There are two ways that I know of to do this in GS2:
PHP Code:

triggeraction(0,0,"clientside",WEAPONNAME,params...);
// You can use '#N' for WEAPONNAME, as #N is the name of the parent weapon 

The second way uses 'triggerclient()', but since I don't know the syntax by heart, I won't post it here. :D

Googi 09-30-2005 12:28 AM

So how do I send a message from the serverside to the clientside for the clientside to execute some clientside commands?

Skyld 09-30-2005 08:46 AM

Quote:

Originally Posted by Googi
So how do I send a message from the serverside to the clientside for the clientside to execute some clientside commands?

NPC Code:
function onCreated()
{
triggeraction(0, 0, "clientside", "weaponname", "lol");
}
//#CLIENTSIDE
function onActionclientside()
{
player.chat = "THIS IS CLIENTSIDE!";
}


Ajira 09-30-2005 08:07 PM

Quote:

Originally Posted by Skyld
NPC Code:
function onCreated()
{
triggeraction(0, 0, "clientside", "weaponname", "lol");
}
//#CLIENTSIDE
function onActionclientside()
{
player.chat = "THIS IS CLIENTSIDE!";
}


Serverside created is not called in weapons.

napo_p2p 09-30-2005 08:10 PM

Quote:

Originally Posted by Ajira
Serverside created is not called in weapons.

I think it is, but not for when the weapon is created for the player, but when it is updated (created).

PHP Code:

function onCreated() {
  echo(
"Test.");


That works on a weapon script when it's updated.

But yes... triggering clientside from a serverside onCreated() in a weapon will not work.

Ajira 09-30-2005 08:12 PM

Quote:

Originally Posted by napo_p2p
I think it is, but not for when the weapon is created for the player, but when it is updated (created).

That does not count. =P


All times are GMT +2. The time now is 01:39 AM.

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