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.