View Single Post
  #1  
Old 03-11-2010, 12:17 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Check when a player was last seen

This little script can show you when a player was last seen on a server. Seems to work from my testing.

A few variables to note:
temp.timeoffset = minutes to offset the time by. This was tested on UN, so I had to offset the time by 23 minutes.

temp.timezone = hours to offset for timezone. I had it set up to 5 to match GMT time.

The above may be wrong, however. It doesn't seem right to ADD the offset of time, as that means the clocks are behind and they're typically ahead... but whatever. Also, account names are case sensitive. This has to do with the way offline player objects are loaded, and really beyond my control unless anyone can come up with a fix.

PHP Code:
function onPlayerLogout(pl) {
  
pl.clientr.seenlast = timevar2;

  
// HMM, BACKUP IN CASE ABOVE FAILS?
  
temp.loadedacc = new TServerPlayer((@pl.account));
  
loadedacc.clientr.seenlast = timevar2;
  
loadedacc.destroy();
}

function 
onActionServerside(cmd,acc) {
  if (
cmd != "LastSeen") return;

  
temp.pl = new TServerPlayer((@acc)); // LOAD OFFLINE PLAYER OBJECT

  // IF PLAYER HAS NO RECORDS OF LOGIN, GIVE ERROR AND RETURN
  
if (pl.clientr.seenlast == 0) {
    
player.chat = acc SPC "has no login records.";
    
pl.destroy();
    return;
  }
  
  
temp.timezone = 5;    // TIMEZONE OFFSET, 5 = GMT
  
temp.timeoffset = 23; // MINUTES OFFSET TO COMPENSATE FOR SHODDY SERVER CLOCKS

  // COMPILE RETURN MESSAGE
  
temp.time = (findplayer(acc) == null ? pl.clientr.seenlast : timevar2)+(timeoffset*60+(timezone*60*60));
  
temp.msg = acc @ " was last seen:" 
             
SPC formatTimeString("%D %I:%M%p",time)
             
SPC "gmt" SPC (findplayer(acc) == null ? "" : "[logged in]");

  
player.chat = msg;          // ECHO TO PLAYER'S CHAT
  
player.sendrpgmessage(msg); // ECHO TO PLAYER'S F2 WINDOW

  
pl.destroy(); // DESTROY PLAYER OBJECT WHEN DONE
}
//#CLIENTSIDE
function onPlayerchats() {
  if (
player.chat.starts("/lastseen")) {
    
temp.acc = player.chat.substring(10);
    
triggerServer("gui",name,"LastSeen",acc);
  }
} 
Reply With Quote