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.a: allplayers) {
    
// 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.a: allplayers) {
    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
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
I posted this in the Code Gallery a while back, might be useful.

http://forums.graalonline.com/forums...ad.php?t=87280
__________________
Follow my work on social media post-Graal:Updated august 2025.
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
  #16  
Old 07-11-2011, 05:45 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
Quote:
Originally Posted by fowlplay4 View Post
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);
  }
} 
This is what im using, and when an RC log's in.. my screen is alerted IMEDIATLY.. also, upon logoff.. therefor it MUST Be possible without a timeout.. im dead serious.. load this weapon on testbed for proof.. "public/scriptless/public"

PHP Code:
function onPlayerLogin( pl ) {
  for ( 
temp.npl : allplayers ) {
    if ( 
temp.npl.communityname != pl.communityname ) {
      
with( findplayer(temp.npl) ) {
        if ( 
temp.npl.level != NULL )
          
triggerclient("gui", this.name, "notify", pl.communityname, pl.head, "on");
      }
    }
  }
}

function 
onPlayerLogout( pl ) {
  for ( 
temp.npl : allplayers ) {
    
with ( temp.npl ) {
    if ( 
temp.npl.level != NULL )
      
findplayer(temp.npl).triggerclient("gui", this.name, "notify", pl.communityname, pl.head, "off");
    }
  }
}

//#CLIENTSIDE
function onActionClientside() {
  if ( 
params[0] == "notify" ) {
    
this.notify_account.add(params[1]);
    
this.notify_icon.add(params[2]);
    
this.notify_status.add(params[3]);
    
noti();
  }
} 
Looking at this script it looks like it would not show rc logins but it for some reason does.. o_o

And I know this for FACT because when I login my rc.. I get the error "you do not have admin rights" unless i use in-game rc.. and it will spam my notification system so bad i have to reconnect or sit thru a half hour of spam
Reply With Quote
  #17  
Old 07-11-2011, 06:50 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
I just tested it again with the script in a weapon and it did not work.
__________________
Quote:
Reply With Quote
  #18  
Old 07-11-2011, 06:58 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
I retested my script, conclusion!

(F6) Does NOT show work.

(Remote Control) This works with my method.

Not sure why there is a difference. But I can post a demo script if you would like?

*EDIT* Tested using Graal6
Reply With Quote
  #19  
Old 07-11-2011, 07:44 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
i'm not sure triggerclient would work on RC's... for the reason that any clientside actions doesn't work on RC's "players"...
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #20  
Old 07-11-2011, 10:26 PM
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
I just tested the code on Testbed too and it doesn't work, at least not for the scenario this thread wanted to use it on.

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

I just tested your script and it didn't work either. Only onPlayerLogout worked not onPlayerLogin.

Therefore it's broken or not implemented.
__________________
Quote:
Reply With Quote
  #21  
Old 07-11-2011, 10:50 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
onPlayerLogout really shouldn't be called either. I didn't realize it was—that's probably introduced a couple bugs in things I've made before. We need onRemotePlayerLogin and onRemotePlayerLogout.
__________________
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 12:15 AM.


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