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 07-07-2011, 02:31 AM
Arch_Angel Arch_Angel is offline
Registered User
Join Date: Apr 2007
Posts: 482
Arch_Angel is on a distinguished road
Send a message via AIM to Arch_Angel
How to detect RC login

Hello. I'm not new to GS2, but I am new to now trying to take it seriously in creating my own things and not just know a few commands and loops and such.

I am currently trying to make a message (or announcement) to echo on RC when a players RC is logged on.

I am using the control NPC to do this, and am wondering if it is possible. Right now I can only get a message to be triggered when the players client logs in. So I have something like.....

PHP Code:
function onCreated()
{
   
this.staff = { "Arch_Angel""Omaster""littlekinky" }
}

function 
onActionPlayerOnline()
{
   if( 
pl.account in this.staff )
   {
      echo( 
"Welcome back " @pl.account );
   }

Now this of course, is aimed to just send the message to RC when the players client logs in. Is there another function or something I can do that would recognize the RC instead?

Sorry if this is so simple, just trying to progress. Thanks ahead for any responses. Will rep accordingly.
Reply With Quote
  #2  
Old 07-07-2011, 04:25 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
check the level name
Reply With Quote
  #3  
Old 07-07-2011, 04:42 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
Unless a function was added to handle it, I've been using a timeout loop. I.e:

PHP Code:
function onCreated() {
  
// Clear array of detected RCs
  
this.lastRCs "";
  
// Start Loop
  
onTimeout();
}

function 
onTimeout() {
  
// Declare an Empty Array for RCs
  
temp.rcs = {};
  
// Loop through All Players currently online
  
for (temp.aallplayers) {
    
// Check if they're in a level
    // No level usually means they're an RC
    
if (temp.a.level == NULL) {
      
// Player's level was NULL
      // Player is actually an RC
      // Add Player to Array of RCs
      
temp.rcs.add(temp.a);
    }
  }
  
// Check if the amount of RCs is greater than the last amount of RCs online.
  
if (temp.rcs.size() > this.lastRCs.size()) {
    
// RCs have logged on.
    
sendtorc("Staff Reminder! You're all special C:");
  }
  
// Record the new array of RCs for the next timeout
  
this.lastRCs temp.rcs;
  
// Continue Looping
  
setTimer(0.5);

That's just a way I've doing it though.

Also instead of maintaining a 'this.staff' array you can just directly reference your server options.

temp.staff = serveroptions.staff.tokenize(",");

The tokenize(",") is just in case someone messes up the array formatting.
__________________
Quote:

Last edited by fowlplay4; 07-07-2011 at 05:11 AM.. Reason: Added comments.
Reply With Quote
  #4  
Old 07-07-2011, 05:00 AM
Arch_Angel Arch_Angel is offline
Registered User
Join Date: Apr 2007
Posts: 482
Arch_Angel is on a distinguished road
Send a message via AIM to Arch_Angel
Quote:
Originally Posted by fowlplay4 View Post
Unless a function was added to handle it, I've been using a timeout loop. I.e:

PHP Code:
function onCreated() {
  
this.lastRCs "";
  
onTimeout();
}

function 
onTimeout() {
  
temp.rcs = {};
  for (
temp.aallplayers) {
    if (
temp.a.level == NULL) {
      
temp.rcs.add(temp.a);
    }
  }
  if (
temp.rcs.size() > this.lastRCs.size()) {
    
// RCs have logged on.
    
sendtorc("Staff Reminder! You're all special C:");
  }
  
this.lastRCs temp.rcs;
  
setTimer(0.5);

That's just a way I've doing it though.

Also instead of maintaining a 'this.staff' array you can just directly reference your server options.

temp.staff = serveroptions.staff.tokenize(",");

The tokenize(",") is just in case someone messes up the array formatting.
little complicated for me to fully understand how you coded everything, but thats a giant help. Thanks, appreciate it.!

rep++ if i can
Reply With Quote
  #5  
Old 07-07-2011, 05:12 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
Quote:
Originally Posted by Arch_Angel View Post
little complicated for me to fully understand how you coded everything, but thats a giant help. Thanks, appreciate it.!

rep++ if i can
I updated my post with the proper documentation for the script, so you should get a better idea of what's actually going on now.
__________________
Quote:
Reply With Quote
  #6  
Old 07-07-2011, 05:20 AM
Arch_Angel Arch_Angel is offline
Registered User
Join Date: Apr 2007
Posts: 482
Arch_Angel is on a distinguished road
Send a message via AIM to Arch_Angel
Quote:
Originally Posted by fowlplay4 View Post
I updated my post with the proper documentation for the script, so you should get a better idea of what's actually going on now.
<3

perfectly explained.
Reply With Quote
  #7  
Old 07-07-2011, 09:21 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
Annoying that we can't get basic events like onRemotePlayerLogin and have to use timeouts for stuff like this.
__________________
Reply With Quote
  #8  
Old 07-07-2011, 09:36 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Like Cubical was suggesting can't you just check to see if the level exists or not with onPlayerLogin(obj)?

Or am I missing something?
Reply With Quote
  #9  
Old 07-07-2011, 09:37 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 ffcmike View Post
Like Cubical was suggesting can't you just check to see if the level exists or not with onPlayerLogin(obj)?

Or am I missing something?
99% certain it's not called when RCs log in.
__________________
Reply With Quote
  #10  
Old 07-07-2011, 09:41 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by cbk1994 View Post
99% certain it's not called when RCs log in.
I'm 100% sure it's called when an RC logs out .

Edit: Yeah that is odd.
Reply With Quote
  #11  
Old 07-07-2011, 01:42 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by ffcmike View Post
Like Cubical was suggesting can't you just check to see if the level exists or not with onPlayerLogin(obj)?

Or am I missing something?
I've never had a reason to try it on login, I assumed that it would work on login because it works on logout.
Reply With Quote
  #12  
Old 07-07-2011, 01:51 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Cubical View Post
I've never had a reason to try it on login, I assumed that it would work on login because it works on logout.
That's Graal man.
__________________
Reply With Quote
  #13  
Old 07-07-2011, 05:56 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
I posted this in the Code Gallery a while back, might be useful.

http://forums.graalonline.com/forums...ad.php?t=87280
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #14  
Old 07-11-2011, 05:26 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
There should be an easier way to do this without timeout.. I have a script currently that shows players who login on your screen like XBL and PSN do.. it uses a funciton when the player logs in.. this also shows rc's... have you tried
on PlayerLogin() I think is the command.. might be wrong its been a while. then do a check for null level..
Reply With Quote
  #15  
Old 07-11-2011, 05:40 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
Quote:
Originally Posted by scriptless View Post
There should be an easier way to do this without timeout.. I have a script currently that shows players who login on your screen like XBL and PSN do.. it uses a funciton when the player logs in.. this also shows rc's... have you tried
on PlayerLogin() I think is the command.. might be wrong its been a while. then do a check for null level..
Only works for players (server-side) not RCs.

PHP Code:
// This code doesn't work!
function onPlayerLogin(pl) {
  if (
pl.level == NULL) {
    
sendtorc("HEY! Listen!" SPC pl.account);
  }

__________________
Quote:
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 04:52 PM.


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