Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Player Classes and Level NPCs (https://forums.graalonline.com/forums/showthread.php?t=134268647)

JohnnyChimpo 08-20-2013 09:09 PM

Player Classes and Level NPCs
 
So i have a class that controls player functions and used the NPC Control to apply this class to all players that log in. I have also made -Message weapon and connected the same player functions to that weapon ( this is for if i call it in a level NPC on clientside). However when i use the player.funct(); on serverside, and say i need that funct() to trigger clientside to display a showtext or something, it gets to the serverside funct() but doesnt go through the trigger. Why would this be? Here is my player_functions class.

Note: The weapon works fine.

PHP Code:

public function sendMsg(){
echo(
"Triggering from serverside");
//this.chat= "hello";
triggerClient("gui"this.name"msg");
}
//#CLIENTSIDE
function onActionClientSide(cmd){
  
this.chat "Hello";
  echo(
"made it");
  
}
public function 
sendMsg(){
echo(
"toast1");



cbk1994 08-20-2013 10:58 PM

You can't trigger a class (since a class just extends something else) or a player object. You need to trigger one of the player's weapons clientside.

JohnnyChimpo 08-21-2013 12:17 AM

I am not understanding. Basically im trying to have a level NPC send a string to be displayed on clientside using showtext/showimg.

My setup:
Class for player_functions, which is joined to the player via NPC control
Level NPC- aka person in house attached to class script with join.

In addition i have a weapon named -Messages which holds the player_functions by join command.

fowlplay4 08-21-2013 12:25 AM

Control-NPC:

PHP Code:

function onActionPlayerOnline() {
  
// other code will likely be in here
  
player.join("player_functions");


class: player_functions

PHP Code:

public function sendMsg(msg) {
  
player.triggerclient("weapon""-Messages""msg"msg);


Weapon: -Messages:

PHP Code:

//#CLIENTSIDE

function onActionClientSide() {
  if (
params[0] == "msg") {
    
displayMessage(params[1])
  }
}

public function 
sendMsg(msg) {
  
displayMessage(msg);
}

function 
displayMessage(msg) {
  echo(
msg);


Example Weapon Usage:

PHP Code:

function onCreated() {
  
findplayer("Example").sendMsg("Hello!");

  
player.sendMsg("Also works."); // when player is available.
}

//#CLIENTSIDE

function onCreated() {
  (
"-Messages").sendMsg("World!");



JohnnyChimpo 08-21-2013 02:35 AM

Okay thank you so much, so this is one of the cases where you wouldn't use this.name for the name of the NPC in triggerclient. Plus i also had it laid out a bit screwy so i'm sure that's part of it as well. thanks again.

cbk1994 08-21-2013 02:58 AM

Quote:

Originally Posted by JohnnyChimpo (Post 1721882)
Okay thank you so much, so this is one of the cases where you wouldn't use this.name for the name of the NPC in triggerclient.

triggerClient works on weapons, not NPCs. You don't use this.name because you're not triggering the player object (which is what this is). Instead you want to trigger a weapon, so you just specify that weapon's name. If you do use triggerClient in a weapon, then it's perfectly valid to use this.name.


All times are GMT +2. The time now is 07:36 PM.

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