Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Passing values from Clientside to Serverside (https://forums.graalonline.com/forums/showthread.php?t=84160)

Tyhm 02-12-2009 01:41 PM

Passing values from Clientside to Serverside
 
Ookay, I had higher hopes for the Stickies, but given that the optimization guide was written in 2004, I guess I'm out of luck:

Are we seriously still using triggeraction to send data from Clientside to Serverside? And are we seriously still using this.rupees, this.darts, this.hearts to change values on Serverside that Clientside can pick up on? I found triggerserver, and that's great for weapons, but I mean - seriously? Are we still tying "the player just hit me" to a code-arrow, shooting it at the serverside, and praying it hits?! I mean, I'm the first to admit I been out of the game for a while, but if there's a better way I'd love to know what it is...

And for those of you who absolutely have to know the context, I'm making a baddy, okay? And right now one baddy runs trigger-to-trigger on the serverside (move to onMovementfinished - and once again, hoorah for a language that buries that tidbit in the newfeatures2001.txt), then looks for an enemy; the clientside looks for an enemy to turn the baddy's head; and the gani runs a timeout too, because it's complicated, (and I'm probably gonna wind up scrapping the gani and moving all that code right back to the clientside script). And right now the only way to tell the Client that the baddy's taken damage is to set this.hearts, and have the client scan it every 0.05 seconds. -_-

Skyld 02-12-2009 02:08 PM

Quote:

Originally Posted by Tyhm (Post 1465644)
Are we seriously still using triggeraction to send data from Clientside to Serverside?

Yes. You can use triggeractions (triggerclient, triggerserver) or you can send data (albeit without events) using client flags or player attrs.
Quote:

Originally Posted by Tyhm
And are we seriously still using this.rupees, this.darts, this.hearts to change values on Serverside that Clientside can pick up on?

What do you mean? When you change these values serverside, they update clientside also.
Quote:

Originally Posted by Tyhm
I found triggerserver, and that's great for weapons, but I mean - seriously? Are we still tying "the player just hit me" to a code-arrow, shooting it at the serverside, and praying it hits?!

I'm not sure what you are even getting at here.
Quote:

Originally Posted by Tyhm
And right now the only way to tell the Client that the baddy's taken damage is to set this.hearts, and have the client scan it every 0.05 seconds. -_-

To be honest, I'm not sure what you were expecting. You could quite easily send a triggeraction to the clientside each time the baddy takes damage but this is exactly the sort of thing you have to do when you involve a server and a client in any application, not just Graal: either poll for changes or wait for events.

Loriel 02-12-2009 02:23 PM

I think what Tyhm is looking for here is triggering the "other" side of the script without involving coordinates or the chance that other scripts might be hit by it.

Tyhm 02-12-2009 02:23 PM

My point is triggerserver/triggerclient seems to be weapons only, edit rupees/hearts/etc seems to be the only set of variables that ARE visible to Client when they're changed on Server. And clientr. are really playerr, apparently....

And yes, callclient(parameters) would be awesome.

Loriel 02-12-2009 02:24 PM

Quote:

Originally Posted by Tyhm (Post 1465657)
rupees/hearts/etc seems to be the only set of variables that ARE visible to Client when they're changed on Server.

Did we not have a bunch of save[i] variables with limited range or something that worked like that too?

Tyhm 02-12-2009 02:37 PM

Ha, yeah, [0]-[9] and 0-220 I think. And bombs and darts (0-99), and probably swordpower and shieldpower, and I can always shoehorn a meaningful #P1 into a gani without a hat to sneak another string in that way; I'd just rather not if there's a better way.

Apparently there is not. -_-

Yet; I fully expect that as soon as I've gone to the trouble something will be released that makes my work unnecessary again...

Inverness 02-12-2009 04:35 PM

Quote:

Originally Posted by Loriel (Post 1465656)
I think what Tyhm is looking for here is triggering the "other" side of the script without involving coordinates or the chance that other scripts might be hit by it.

If you have an NPC's ID and level name, you can send it to a triggerserver/client and simply use functions to locate the NPC object.

These are two functions extracted from my triggercontrol class that is used to wrap the triggerserver() and triggerclient() in weapons:
PHP Code:

public function npcfunction(lvlnamenpcidfuncnamep3p4p5p6p7p8p9) {
  for (
temp.ifindlevel(temp.lvlname).npcs) {
    if (
temp.i.id == temp.npcid) {
      return 
temp.i.(@ temp.funcname)(temp.p3temp.p4temp.p5temp.p6temp.p7temp.p8temp.p9);
    }
  }
}
//#CLIENTSIDE
public function npcfunction(npcidfuncnamep2p3p4p5p6p7p8p9) {
  return 
findnpcbyid(temp.npcid).(@ temp.funcname)(temp.p2temp.p3temp.p4temp.p5temp.p6temp.p7temp.p8temp.p9);


Call clientside part of an NPC from serverside, assuming I have a calling player, I can:

WeaponName.ClientFunction(null, "npcfunction", this.id, "saystuff", "lol I like pancakes");

Or from the client:

WeaponName.ServerFunction(null, "npcfunction", this.level.name, this.id, "saystuff", "Inverness was here");


Note that ClientFunction() and ServerFunction() are part of my class, they call a function on the other side and wait for return value. Naturally, I would prefer a hard-coded function, as it would be more efficient.

Tyhm 02-13-2009 02:48 AM

Huh?
Yeah, but triggerserver and triggerclient are NPCW only, right?

cbk1994 02-13-2009 04:06 AM

Quote:

Originally Posted by Tyhm (Post 1465940)
Huh?
Yeah, but triggerserver and triggerclient are NPCW only, right?

You can use

PHP Code:

triggerserver("gui""blah");
triggerserver("weapon""blah"); // same as gui
triggerserver("npc""blah"); 

For NPCs, you can do:

PHP Code:

findNPC(npc).trigger("ActionServerside""foo"); 

(though you can use something else as well).

Tyhm 02-13-2009 05:41 AM

Thanks. Godforbid the wiki be up to date...-_-


All times are GMT +2. The time now is 04:30 PM.

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