Graal Forums

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

Chandler 04-04-2007 08:24 AM

Clientside Classes
 
Having a bit of a problem. I'm having problems joining a class to a player when the log online.
Here's what I have so far, it just doesn't seem to interact with the player, at all.

HTML Code:

//#CLIENTSIDE
function onCreated()
  {
  player.join("player_weapon");
  player.doAction({"drawMaps", "defaultStats"});
  }

Inside the "player_weapon"

HTML Code:

//#CLIENTSIDE 
function onCreated()
  echo("GOT THE MAIN CONTROL!");
 
public function doAction(actionNames)
  for (temp.currentAction: temp.actionNames)
    this.(@ temp.currentAction)();

Neither are being called... suggestions? thanks!

Inverness 04-04-2007 08:27 AM

You can't, shouldn't, join classes on the Clientside, it needs to be done Serverside.

And if its done Serverside, I think the Clientside and Serverside player objects are not the same so It would only effect the serverside player.

Chandler 04-04-2007 08:31 AM

Quote:

Originally Posted by Inverness (Post 1296643)
You can't, shouldn't, join classes on the Clientside, it needs to be done Serverside.

And if its done Serverside, I think the Clientside and Serverside player objects are not the same so It would only effect the serverside player.

That's what I thought!
So there isn't a way to use "player." clientside?

Inverness 04-04-2007 08:34 AM

Not that I know of :(
Set up global references on the clientside that lead to the object with the function.

Chandler 04-04-2007 08:41 AM

Thanks, I'll see what I can do!

Gambet 04-04-2007 05:16 PM

You can always use attr's to access the information clientside and then send it over serverside when you're done to save or so.

Kristi 04-04-2007 05:33 PM

Quote:

Originally Posted by Chandler (Post 1296642)
Having a bit of a problem. I'm having problems joining a class to a player when the log online.
Here's what I have so far, it just doesn't seem to interact with the player, at all.

HTML Code:

//#CLIENTSIDE
function onCreated()
  {
  player.join("player_weapon");
  player.doAction({"drawMaps", "defaultStats"});
  }

Inside the "player_weapon"

HTML Code:

//#CLIENTSIDE 
function onCreated()
  echo("GOT THE MAIN CONTROL!");
 
public function doAction(actionNames)
  for (temp.currentAction: temp.actionNames)
    this.(@ temp.currentAction)();

Neither are being called... suggestions? thanks!

well, for the onCreated in the class, essentially you are creating player.onCreated(), so that just isnt going to be called.

as for the doAction, you are calling player.drawMaps() and player.defaultStats(), since you are joining the class to the player, the player now becomes the object, so "this" will refer to the player. Since the player does not have those functions, they are not being called. In this case, it shouldn't have been joined to the player in the first place.

Joining a class to a player clientside sure does work :)

Chandler 04-04-2007 07:03 PM

Quote:

Originally Posted by Kristi (Post 1296718)
well, for the onCreated in the class, essentially you are creating player.onCreated(), so that just isnt going to be called.

as for the doAction, you are calling player.drawMaps() and player.defaultStats(), since you are joining the class to the player, the player now becomes the object, so "this" will refer to the player. Since the player does not have those functions, they are not being called. In this case, it shouldn't have been joined to the player in the first place.

Joining a class to a player clientside sure does work :)

I don't quite understand, could you show an example? thanks!!

Kristi 04-04-2007 07:13 PM

Quote:

Originally Posted by Chandler (Post 1296753)
I don't quite understand, could you show an example? thanks!!

class: coolness
PHP Code:

//#CLIENTSIDE
public function pointlessChat() {
  
this.chat "takeover!";


someweapon
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
player.join("coolness");
}

function 
onPlayerChats() {
  
// Take over chat... pointlessly
  
player.pointlessChat();


With this weapon on your person, if you talk, your chat will change to takeover!

Inverness 04-04-2007 07:24 PM

...
Why would joining classes even work clientside, isn't that a security issue?

Crow 04-04-2007 07:33 PM

Quote:

Originally Posted by Inverness (Post 1296757)
...
Why would joining classes even work clientside, isn't that a security issue?

What?O.o

Inverness 04-04-2007 07:34 PM

Quote:

Originally Posted by Crow (Post 1296763)
What?O.o

With all those fancy hacks people come up with for Graal. And I don't really know how secure the client is. I'm just being paranoid. :D

Crow 04-04-2007 07:42 PM

Quote:

Originally Posted by Inverness (Post 1296764)
With all those fancy hacks people come up with for Graal. And I don't really know how secure the client is. I'm just being paranoid. :D

You cant really edit classes ;o
And Graal is...well...not secure ^^

Kristi 04-04-2007 07:53 PM

Quote:

Originally Posted by Inverness (Post 1296757)
...
Why would joining classes even work clientside, isn't that a security issue?

Well, its not joining the serverside, so... anything that can be joined by a therodical hack could have just been hacked there in the first place.

Admins 04-04-2007 10:48 PM

Joining classes works on clientside, but with 4.20 the onCreated() thing is not necessary called when the script has not been loaded yet. In the next Graal version clientside classes work much better (I'm using it for customized gui controls and such stuff).
About security: client-side objects can join any class that have a clientside script. It shouldn't really be a problem because (1) you need to be able to write the script that calls "join", so you basicly need RC already, (2) in that case you could also easily call join on serverside, so you don't win anything, and (3) even if someone hacks the client and manages to join another class, he/she can only use scripts which are meant for clientside stuff anyway, (4) it might be possible to add a server option to restrict client-side joining to certain classes, although I don't see a case where that could be necessary


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

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