Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-28-2012, 11:19 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
Way to detect when a player logs off?

I have detection for when players log in but not off.
Basically I have coded my own playercount using PHP.
It uses a static image and adds text to it dynamically when players log on.
If no one logs on it updates every 5 minutes by requesturl.
Anyway here is the image for anyone that's interested.
I might release the source if people want it.
Also is there a way to detect when RC players log on?

http://wr3ckless.net/text/playercount.png
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #2  
Old 02-28-2012, 12:29 PM
jamitsu89 jamitsu89 is offline
Registered User
Join Date: Jun 2011
Posts: 27
jamitsu89 is an unknown quantity at this point
Considering you already have the framework for the update every 5 minutes, you can just do something similar to:

NPC Code:

function checkPlayers() {
for (temp.pl : allplayers) {
if (temp.pl.level.size <= 0) {
//This is an RC
temp.rccount ++;
} else {
//This is a player
temp.pcount++;
}
}
//Then store temp.rccount and temp.pcount here
}



Also possibly onPlayerLogout()
Reply With Quote
  #3  
Old 02-28-2012, 01:19 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
I already have something very similar to that to check for players
it's just how to check when they log on to RC or off of RC or log off of the server.
I would prefer to update it when players leave or enter rather than every 5 minutes.
This way it's more accurate.
Thanks for the help and I'll look into onPlayerLogout() Possibly onPlayerlogout()
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #4  
Old 02-28-2012, 02:19 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
Quote:
Originally Posted by Gunderak View Post
Also is there a way to detect when RC players log on?
Graal Script Code:
function onPlayerLogin(temp.object)
{
  
// Let's check if it's a player object to begin with. I could be mistaken, but I vaguely remember IRC channels or something triggering this.
  
if (temp.object.account == "")
    return;
  
  
// Ok, it's a player. Let's check if it's an RC or not by reading the level name.
  
if (temp.object.level.name == "") {
    
// Not in a level, must be an RC!
  
}
  else {
    
// The player is in a level, so it's not an RC.
  
}

Substitute onPlayerLogin with onPlayerLogout for the other way around.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 02-28-2012, 02:51 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
No reason to read the level name string, just check the level object.

Graal Script Code:
if (temp.pl.level == null) { // it's an RC! 
__________________
Reply With Quote
  #6  
Old 02-28-2012, 02:52 PM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
Updating every 5 minutes is a good standard in my opinion. You don't want someone logging in, logging out and sending a request every 1 second either... You should have a delay.

If you cant do it any other way, last resort would be to check the size of 'allplayers' and compare to the previous size on a loop. If its changed, obviously someone has logged out/in.
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote
  #7  
Old 02-28-2012, 10:47 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
Considering it would use about 1kb bandwidth to communicate with the PHP script, it's not a big deal if someone logs off then on.
As I said, I want it to be as accurate as possible.
Thanks for all the help.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:44 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.