Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-20-2013, 09:09 PM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
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");

Reply With Quote
  #2  
Old 08-20-2013, 10:58 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #3  
Old 08-21-2013, 12:17 AM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
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.
Reply With Quote
  #4  
Old 08-21-2013, 12:25 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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!");

__________________
Quote:

Last edited by fowlplay4; 08-21-2013 at 03:19 AM..
Reply With Quote
  #5  
Old 08-21-2013, 02:35 AM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
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.
Reply With Quote
  #6  
Old 08-21-2013, 02:58 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by JohnnyChimpo View Post
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.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:06 AM.


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