Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Serverside/Clientside problems (https://forums.graalonline.com/forums/showthread.php?t=134260075)

Jiroxys7 08-05-2010 03:37 AM

Serverside/Clientside problems
 
Okay, i have two scripts that this has affected so far. One is a damage text script that creates particles. i have it in a gani yet the text will only show if you are the one who get's damaged. but only for the person who was damaged.
example: person A hits person B. person B sees damage text. person A does not.

Secondly I have a weapon that spawns daggers to move around you. problem is, it suffers a similar problem.
player A uses the item. the daggers are rotating around player A. (correct)
to player B, the daggers are rotating around player B, and not player A. (incorrect)

I'm trying to combat this by replacing the player.x and player.y's with variables taken from the npcdropper.

Problem is, the stupid class can only read this.dropper from the serverside. and i cant seem to send that data over to the clientside with triggeraction nor triggerclient. (wtf? !pissed!)

So any tips on the gani? and what command should i be using for the class to send the data over from server to client?

dereklarue 08-16-2010 01:26 AM

Quote:

Originally Posted by Jiroxys7 (Post 1591469)
So any tips on the gani? and what command should i be using for the class to send the data over from server to client?

I don't think you can send data to client side in a class, at least for all i know.
The join function only goes one way, from A to B, not B to A. 'A' being a player weapon and 'B' being a class. When sending data over to a class, be sure to send everything needed. You could add a Clientside part to the class and use a trigger. :p

MrOmega 08-16-2010 02:46 AM

in a class the only way I really know of sending data across the client-server barrier is setting vars to attr[ #] and checking on the other side for that attr

EDIT: I also remember Invern making a pretty good function pack for communicating across the barrier.
Here's the link Client <-> Serverside Function Caller
Maybe this can help you a bit, it's helped me before.

Switch 08-16-2010 04:49 AM

Your problem is that the particles/images are on the client side, not the server side. To make everyone able to see them you need to make a Gani script.
Ex:
PHP Code:

GANI0001

LOOP
CONTINUOUS
DEFAULTATTR1 hat0
.png
DEFAULTHEAD head19
.png
DEFAULTBODY body
.png

SCRIPT
function onPlayerEnters() {
  
drawImages();
}
function 
drawImages() {
  
// yada yada
}
SCRIPTEND

ANI
ANIEND 

Also, classes themselves can't trigger the client from the server if not joined by a weapon.

Jiroxys7 09-15-2010 11:44 PM

Quote:

Originally Posted by MrOmega (Post 1594382)
in a class the only way I really know of sending data across the client-server barrier is setting vars to attr[ #] and checking on the other side for that attr

EDIT: I also remember Invern making a pretty good function pack for communicating across the barrier.
Here's the link Client <-> Serverside Function Caller
Maybe this can help you a bit, it's helped me before.

Been trying to get the thing working for an hour. I've tried it before with no luck. And this time around it still won't work for me. even following Chompy's 'guide' didnt work (unless I need the class triggercontrol, which, if this is the case, i dont have because it isnt posted on there anyway)

Why can't Stefan allow triggerclient and triggerserver in classes anyway? :\
This is giving me a headache..

Skyld 09-15-2010 11:49 PM

Quote:

Originally Posted by Jiroxys7 (Post 1600954)
Why can't Stefan allow triggerclient and triggerserver in classes anyway? :\
This is giving me a headache..

You are talking about classes like they are something that they aren't. A class in GScript is essentially an include; you can join a class to a weapon, in which case the class code will work like it's in a weapon, or you can join a class to an NPC, in which case the class code will work like it's in an NPC.

When joining to a weapon you can triggerclient and triggerserver normally, even from inside the class (like triggerserver("gui", this.name, …)). When joining to an NPC of some kind you probably want more to send triggeractions onto the NPC's coordinates.

Jiroxys7 09-16-2010 12:14 AM

Anywho, I'm now trying to work on a simplified version of inverness' workaround in which you can join the class to a weapon (that every player will have), then trigger a public function in the weapon while sending over some params, use triggerclient/server on itself, sending over the params, then triggering a public function in the class, sending over the params.

but when the weapon hits the triggerclient part, i immediately get a callstack overrun error. I have no clue what that is supposed to mean. any tips on what causes this?

Also @ Skyld, It really doesn't seem like it would be too hard to achieve. Especially knowing that it's possible to do a hackaround, a similar effect should be able to be hardcoded into graal.

edit: and triggeraction doesnt seem to work like this (i must be doing something wrong. what it is, i have no clue) and I'm really just trying to get the name of the account that put the npc. I dont get why that needs to be sent through a bajillion different scripts to get :(

fowlplay4 09-16-2010 12:47 AM

Basic client -> server interaction for a level NPC.

PHP Code:

function onCreated() {
  
// Gives the triggeraction something to hit on the server-side
  
this.setshape(13232);
}

function 
onActionExample(npcid) {
  if (
params[0] == npcid) {
    
this.chat "Trigger received from" SPC player.account "!";
  }
}

//#CLIENTSIDE

function onPlayerChats() {
  if (
player.chat == "example"triggerExample();
}

function 
triggerExample() {
  
triggeraction(this.1this.1"Example"this.id);


I've never had a reason to send a message back to the level NPC specifically though, your code can probably re-factored or sent directly to the Weapon NPC via triggerclient that needs the information from the server.

Jiroxys7 09-16-2010 01:04 AM

I'm actually trying to send a param server -> client. I think it was cbk that got me into the habit of putting npc.dropper = player.account; after my putnpc2's. The problem is, this.dropper can only be read from the clientside. and since I have my damage system and stat system on the clientside (so i can loop them faster without bogging down the npcserver and whatnot), when the damage near the npc is dealt, since it has to read from the npc dropper's stats, i need to send that player's account name though the clientside portion of the script. (in fact, when i first tried this, i was reading client.vars when it dealt damage, just to find out that it was reading off of each individual player's stats. causing players to receive a very wide variety of damage)

I really dont see why the npcdropper can't be automatically placed in the npc's variables when it's created on both the client and on the serverside portion of it.


but I digress.. I tried to invert that script so it goes server -> client but it didnt seem to work. I'm going to keep trying though. but just to make sure, triggeraction can trigger clientside functions too right? (Hoping the answer is yes because if not...)

edit: if not, maybe i could just move the damage triggers in the npc over to the serverside, then copy part of the damage portion of my weapon script onto the serverside. and then send over the data to the client from there.

fowlplay4 09-16-2010 01:56 AM

The additional trigger required to make your system run properly pretty much nullifies the efficiency bonus (if there actually is one) of having it processed on the client. So yes you should have the onActionDamage in the server-side portion.


All times are GMT +2. The time now is 09:55 AM.

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