Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-25-2005, 06:01 PM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
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)?
__________________
Reply With Quote
  #2  
Old 09-25-2005, 07:26 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
__________________
Skyld
Reply With Quote
  #3  
Old 09-29-2005, 10:06 PM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to 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?

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?
__________________
Reply With Quote
  #4  
Old 09-29-2005, 10:27 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
__________________
Skyld

Last edited by Skyld; 09-29-2005 at 11:11 PM..
Reply With Quote
  #5  
Old 09-30-2005, 12:18 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
I can trigger from the serverside to the clientside too, right?
__________________
Reply With Quote
  #6  
Old 09-30-2005, 12:25 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
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.
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #7  
Old 09-30-2005, 12:28 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
So how do I send a message from the serverside to the clientside for the clientside to execute some clientside commands?
__________________
Reply With Quote
  #8  
Old 09-30-2005, 08:46 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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!";
}

__________________
Skyld
Reply With Quote
  #9  
Old 09-30-2005, 08:07 PM
Ajira Ajira is offline
Poont.
Join Date: Oct 2004
Location: NY, USA
Posts: 477
Ajira is on a distinguished road
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.
__________________
Liek omigosh.

Reply With Quote
  #10  
Old 09-30-2005, 08:10 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
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.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #11  
Old 09-30-2005, 08:12 PM
Ajira Ajira is offline
Poont.
Join Date: Oct 2004
Location: NY, USA
Posts: 477
Ajira is on a distinguished road
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
__________________
Liek omigosh.

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:23 AM.


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