Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   clientr strings? (https://forums.graalonline.com/forums/showthread.php?t=70634)

Chompy 12-07-2006 07:20 PM

clientr strings?
 
Let's see, I've had a quite annoying problem, sometimes I can't read clientr. strings serverside, some cleintr strings are readable, and some are not.
Here's some examples of my problem:

PHP Code:

function onCreated()
  echo( 
findplayer"Chompy").clientr.mud_maxhp); 

returns 5 (clientr.mud_maxhp is setted to 5 in player attributes)

PHP Code:

function onCreated()
  echo( 
player.clientr.mud_maxhp); 

or
PHP Code:

function onCreated()
  echo( 
clientr.mud_maxhp); 

Returns nothing...
the clientr string is setted serverside in a class..


Well, any thoughts?

contiga 12-07-2006 08:05 PM

The *.mud* strings are protected, they are reserved for GK. Better use md_ for example.

Chompy 12-07-2006 08:35 PM

Quote:

Originally Posted by contiga (Post 1251158)
The *.mud* strings are protected, they are reserved for GK. Better use md_ for example.

Hmm, weird. I can recieve them by using findplayer(), but I'll try rename the strings

Twinny 12-08-2006 03:18 PM

Quote:

Originally Posted by Chompy (Post 1251154)
PHP Code:

function onCreated()
  echo( 
player.clientr.mud_maxhp); 

or
PHP Code:

function onCreated()
  echo( 
clientr.mud_maxhp); 


Is it safe to assume you did these clientside?

I've come to use
PHP Code:

function onCreated()
{
  
temp.findplayer("Twinny");
  
temp.e.clientr.hp temp.e.clientr.maxhp;
  echo(
temp.e.clientr.mudregion);



Chompy 12-08-2006 03:54 PM

Quote:

Originally Posted by Twinny (Post 1251442)
Is it safe to assume you did these clientside?

I've come to use
PHP Code:

function onCreated()
{
  
temp.findplayer("Twinny");
  
temp.e.clientr.hp temp.e.clientr.maxhp;
  echo(
temp.e.clientr.mudregion);



I did use them serverside, they were fine readable clientside,
but I changed the start of the string (it was .mud_), and now it works quite fine..
dunno why.. might be with what contiga said :)

contiga 12-08-2006 06:34 PM

Quote:

Originally Posted by Chompy (Post 1251450)
I did use them serverside, they were fine readable clientside,
but I changed the start of the string (it was .mud_), and now it works quite fine..
dunno why.. might be with what contiga said :)

It indeed is what I said ^^

Chompy 12-08-2006 06:42 PM

Quote:

Originally Posted by contiga (Post 1251484)
It indeed is what I said ^^

Thanks :)

Yen 12-08-2006 11:27 PM

I don't think mud_ strings are sent to the client.

Admins 12-09-2006 02:45 AM

clientr.mud_ strings are just not saved and not accepted by the npcserver (you cannot set them with RC as far as I know), but they should work fine.

I guess the problem of the original poster lies in the placement of the code, it would be interesting to know in what class/object that onCreated() function is put. When it is an npc, then it is normal that there is no player. object. If the player has joined a class and onCreated() is placed in that class, then it is better to use "this.clientr...". The code in the original post should still work in that case though, it might not be called at all though if the player already joined some other class before and is so not "created" a second time (onCreated() is only called when the script object is initialized).

Chompy 12-09-2006 04:24 PM

Quote:

Originally Posted by Stefan (Post 1251584)
clientr.mud_ strings are just not saved and not accepted by the npcserver (you cannot set them with RC as far as I know), but they should work fine.

I guess the problem of the original poster lies in the placement of the code, it would be interesting to know in what class/object that onCreated() function is put. When it is an npc, then it is normal that there is no player. object. If the player has joined a class and onCreated() is placed in that class, then it is better to use "this.clientr...". The code in the original post should still work in that case though, it might not be called at all though if the player already joined some other class before and is so not "created" a second time (onCreated() is only called when the script object is initialized).

Hmm, I setted the strings inside a class, serverside (player.join())

example of how I did it:

+Initialize
PHP Code:


player
.join"initialize");

function 
onActionServerside() {
  switch( 
params0]) {
    case 
"init":
      
player.mud_initialize();
    break;
  }
}

//#CLIENTSIDE
function onCreated() {
  
onPlayerEnters();
}

function 
onPlayerEnters() {
  if ( !( 
clientr.mud_player_joined)) {
    
triggerserver"gui""+Initialize""init");
  }


class: initialize
PHP Code:


public function mud_initialize() {
  
// setting of strings here
  
clientr.mud_player_joined true;


When player logs on, and clientr.mud_player_joined is false,
it triggers and do a player join on serverside, inside the class
the strings are setted.. Is this method correct, or should I use an other way?

Admins 12-09-2006 05:16 PM

Better let the player join the class directly at login, in the control-npc in onActionPlayerOnline() or by using the event onPlayerLogin(playerobject) in any other script. In your example it would call the thing several times and would still not guarantee that its working. Also use this.clientr.flagname in the initialize class instead of clientr.flagname.

Chompy 12-09-2006 06:55 PM

Quote:

Originally Posted by Stefan (Post 1251648)
Better let the player join the class directly at login, in the control-npc in onActionPlayerOnline() or by using the event onPlayerLogin(playerobject) in any other script. In your example it would call the thing several times and would still not guarantee that its working. Also use this.clientr.flagname in the initialize class instead of clientr.flagname.

In the originally script, it has an echo in the class, and
it always echo up to 2-3 times, so.. I'll set it with
this.client.flagname when setting it, and join on logon. I'll try that :]

Btw, onPlayerLogin() works in every wnpcs (serverside) ?
And onActionPlayerLogin() would work in al dnpcs?

Admins 12-09-2006 07:10 PM

onActionPlayerOnline(): for the Control-NPC only
onPlayerLogin(playerobject): for all server-side npcs (including weapon-npcs), do playerobject.join() etc. instead of player.join()

Chompy 12-09-2006 08:40 PM

Quote:

Originally Posted by Stefan (Post 1251660)
onActionPlayerOnline(): for the Control-NPC only
onPlayerLogin(playerobject): for all server-side npcs (including weapon-npcs), do playerobject.join() etc. instead of player.join()

Thanks :D

btw, do onActionPlayerOnline() return any objects/params?

Admins 12-10-2006 02:18 PM

I don't think, it's just an parameter-less event like onPlayerChats and similar

Chompy 12-10-2006 02:50 PM

Quote:

Originally Posted by Stefan (Post 1251957)
I don't think, it's just an parameter-less event like onPlayerChats and similar

Hmm ok :] Thanks :D
Now I just need to figure out something else (related to loadvars and such)


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

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