Aller au contenu

Photo

Booting Players


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Madasahatter

Madasahatter
  • Members
  • 111 messages
I need the ability to boot players afer a configurable amount of time and only in certain areas.

Can anyone help.

#2
eeriegeek

eeriegeek
  • Members
  • 47 messages
void BootPlayerHandler (object oPC) {
    SendMessageToPC(oPC,"Booting...");
    if (GetIsObjectValid(oPC)) BootPC(oPC);
}

void BootPlayer (object oPC, string sMessage) {
    SendMessageToPC(oPC,"Sorry, you are about to be booted: " + sMessage);
    DelayCommand(13.0f,BootPlayerHandler(oPC));
}

you can call BootPlayer from your area's OnEnter event or any other logic that decides to boot them.

EDIT: Added check for valid player object to avoid crashes.

Modifié par eeriegeek, 05 juillet 2011 - 03:34 .


#3
Madasahatter

Madasahatter
  • Members
  • 111 messages
Sorry I forgot to mention only boot when inactive for a configurable about of time and only in certain areas.

#4
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
carefull eeriegeek,

FunkySwerve wrote...
Yes. If you boot a character that's already left the server, it will crash. Use a wrapper when booting:

void DoBoot(object oPC)
{
  if (GetIsObjectValid(oPC))
  {
     BootPC(oPC);
  }
}
Funky

 

#5
eeriegeek

eeriegeek
  • Members
  • 47 messages
Thanks Lightfoot, I added a check to the sample code. I did test a number of times on my server without the check for a valid PC object (Linux 1.69 w/ NWNX) but was unable to crash it with this method. Still, better safe than sorry, there may be other configurations or under heavy loads it may be more of a problem.

#6
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages

eeriegeek wrote...

Thanks Lightfoot, I added a check to the sample code. I did test a number of times on my server without the check for a valid PC object (Linux 1.69 w/ NWNX) but was unable to crash it with this method. Still, better safe than sorry, there may be other configurations or under heavy loads it may be more of a problem.

The problem only occurs if you boot someone that's already been booted or left. You can often get away with booting without a validity check, but it'll bite you sooner or later. Afaik this is still a problem in 1.69, but I could be wrong.

Funky