Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Can't join classes. (https://forums.graalonline.com/forums/showthread.php?t=134260098)

Jiroxys7 08-07-2010 12:11 AM

Can't join classes.
 
I've done this in the past. so perhaps I just forgot how to join the classes. But it's not working. Is this correct?:

NPC:
PHP Code:

//#CLIENTSIDE
function onCreated(){
  
player.join("player_classtest"); 
  
player.chat "Class should be joined now";


Class player_classtest:
PHP Code:

//#CLIENTSIDE
function onPlayerchats(){
  if(
player.chat == "/testclass"){
    
player.chat "It works!";
    echo(
"It really works!");
  }


What am I doing wrong this time? >_<

DustyPorViva 08-07-2010 12:12 AM

Try joining it on the serverside.

Jiroxys7 08-07-2010 12:18 AM

Quote:

Originally Posted by DustyPorViva (Post 1591797)
Try joining it on the serverside.

I believe I've tried that already but I'll give it another shot.

edit: no luck.

cbk1994 08-07-2010 12:46 AM

onPlayerChats isn't an event of the player object.

fowlplay4 08-07-2010 12:52 AM

Quote:

Originally Posted by cbk1994 (Post 1591804)
onPlayerChats isn't an event of the player object.

Yes.

this.join instead of player.join.

Jiroxys7 08-07-2010 01:02 AM

Quote:

Originally Posted by cbk1994 (Post 1591804)
onPlayerChats isn't an event of the player object.

So.. you're saying that I use such functions in a class, nor list a set of custom functions in a class?

Okay, would I be able to do this in an NPC? (I guess theyre called DBNPCs? The ones under the dragon icon.)

If so, how would I communicate between a weapon and a dbnpc?

edit:
Quote:

Originally Posted by fowlplay4 (Post 1591805)
Yes.

this.join instead of player.join.

o. thanks, I'll try that!

cbk1994 08-07-2010 01:20 AM

When you join something you're basically copying and pasting the code into that weapon. If you join it to the player you can add extra functions to the player (like player.unstick()) but you can't use stuff like onKeyPressed and onPlayerChats which aren't events of the player.

Your code should look like this (and be in a weapon):

PHP Code:

function onCreated() {
  
this.join("myclass");
}

//#CLIENTSIDE
function onCreated() {
  
player.chat "it works!";




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

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