Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   If there's a way..? (https://forums.graalonline.com/forums/showthread.php?t=78276)

Switch 01-08-2008 01:39 AM

If there's a way..?
 
Can you (in general, not juat YOU) access the server-side part of a NPC in a level?
How? Every time I try I can't seem to be able to...

DustyPorViva 01-08-2008 01:42 AM

I haven't found an easy way to communicate serverside<>clientside with DBNPC's and level NPC's yet. I tried creating a bomb with clientside effects but had to drop it because I couldn't destroy it on the serverside(globally) while still having clientside effects.

Switch 01-08-2008 01:46 AM

Hmm.
Is it possible, then, to make a Database NPC with say, all things that you want to "drop to pick up", and all of it would be serversided, like normal?

Inverness 01-08-2008 03:45 AM

Communicating clientside<->serverside with any object is as simple as creating a global variable pointing to that object and keeping track of them for garbage collecting.

Though perhaps I could be of further assistance if more details were provided.

xXziroXx 01-08-2008 06:02 PM

Data can be saved in the NPC's attributes (attr[#]) and be read/altered from clientside and serverside.

DustyPorViva 01-08-2008 06:05 PM

Communicating information is easy enough with attr[]'s, but what about actual function calling?

Inverness 01-08-2008 07:33 PM

Like I said, make a name for the object.

xXziroXx 01-08-2008 11:49 PM

Quote:

Originally Posted by Inverness (Post 1368847)
Like I said, make a name for the object.

Yeah, what Inverness said.

Kyranki 01-09-2008 01:17 AM

Correct me if I'm wrong, but if I use the npcs[] array on the serverside shouldn't I be able to access the serverside section of level ncps? I've never really made a point to do so but basic scripting theory would suggest this possible?

Admins 01-09-2008 04:17 PM

You can communicate with server- and client side using the triggerserver/triggerclient functions, e.g. to communicate with a dbnpc you can use triggerserver("npc", npcname, parameters) which will invoke onActionServerSide on the npc, or use triggerserver("weapon", weaponname, parameters) to let the serverside part of the weapon do something.

Crow 01-09-2008 04:26 PM

That reminds me of timevar3...when will the client finally support this? :P

Switch 01-09-2008 10:59 PM

Quote:

Originally Posted by Stefan (Post 1368914)
You can communicate with server- and client side using the triggerserver/triggerclient functions, e.g. to communicate with a dbnpc you can use triggerserver("npc", npcname, parameters) which will invoke onActionServerSide on the npc, or use triggerserver("weapon", weaponname, parameters) to let the serverside part of the weapon do something.

You should update the GraalEditor to:
Use GS2 (if it'd not be so memory consuming), allow more BIT on files, like tiles, and to "triggernpc(x,y,params,..)" which x,y triggers an NPC IN THAT LEVEL with those coords.
Also allow more BIT in GraalShop :p

Kristi 01-10-2008 12:21 AM

if you're talking about having serverside npcs talk to each other even if they're level npc's, give it a name.

on the serverside part, do this
function onCreated() {
mylevelnpc = this;
}

now from any other script serverside, you can call it's public functions by doing mylevelnpc.functionname(); in another npc.

Skyld 01-10-2008 12:34 AM

Quote:

Originally Posted by Crow (Post 1368915)
That reminds me of timevar3...when will the client finally support this? :P

It already does support it, it's just that it is currently only synchronised when in Graal3D mode.

coreys 01-10-2008 01:21 AM

Quote:

Originally Posted by Kristi (Post 1368964)
if you're talking about having serverside npcs talk to each other even if they're level npc's, give it a name.

on the serverside part, do this
function onCreated() {
mylevelnpc = this;
}

now from any other script serverside, you can call it's public functions by doing mylevelnpc.functionname(); in another npc.

You could also use level vars, couldn't you?

Inverness 01-10-2008 01:55 AM

levels vars are just this. variables in the level object.

Switch 01-10-2008 02:24 AM

Quote:

Originally Posted by Kristi (Post 1368964)
if you're talking about having serverside npcs talk to each other even if they're level npc's, give it a name.

on the serverside part, do this
function onCreated() {
mylevelnpc = this;
}

now from any other script serverside, you can call it's public functions by doing mylevelnpc.functionname(); in another npc.

I'm talking about getting from clientside to serverside IN A LEVEL NPC.

napo_p2p 01-10-2008 04:00 AM

Quote:

Originally Posted by Switch (Post 1368988)
I'm talking about getting from clientside to serverside IN A LEVEL NPC.

Quote:

Originally Posted by Switch
"triggernpc(x,y,params,..)" which x,y triggers an NPC IN THAT LEVEL with those coords.

You can use triggeraction to do just that ... (just make sure you set the NPCs shape).

Just an example:
PHP Code:

function onCreated() {
  
setshape(13232);
}

function 
onActionMessage(msg) {
  
this.chat temp.msg;
}

//#CLIENTSIDE
function onPlayerChats() {
  
triggeraction(this.xthis.y"message"player.chat);



coreys 01-10-2008 04:05 AM

Quote:

Originally Posted by Inverness (Post 1368984)
levels vars are just this. variables in the level object.

Yeah...I know. But using level vars could work well in certain cases, I think, for this.

Switch 01-10-2008 04:32 AM

Quote:

Originally Posted by napo_p2p (Post 1369015)
You can use triggeraction to do just that ... (just make sure you set the NPCs shape).

Just an example:
PHP Code:

function onCreated() {
  
setshape(13232);
}

function 
onActionMessage(msg) {
  
this.chat temp.msg;
}

//#CLIENTSIDE
function onPlayerChats() {
  
triggeraction(this.xthis.y"message"player.chat);



Really?
Must have not worked last time because I didn't set set a shape :\
Thanks!

Crow 01-10-2008 03:23 PM

Quote:

Originally Posted by Skyld (Post 1368967)
It already does support it, it's just that it is currently only synchronised when in Graal3D mode.

Thats what I was talking about, sorry for not being clear.


All times are GMT +2. The time now is 11:41 PM.

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