Author Topic: Booting Players  (Read 326 times)

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Booting Players
« on: July 03, 2011, 08:33:19 pm »


               I need the ability to boot players afer a configurable amount of time and only in certain areas.

Can anyone help.
               
               

               
            

Legacy_eeriegeek

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +0/-0
Booting Players
« Reply #1 on: July 03, 2011, 09:42:29 pm »


               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 .
                     
                  


            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Booting Players
« Reply #2 on: July 04, 2011, 05:53:11 pm »


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

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Booting Players
« Reply #3 on: July 04, 2011, 07:17:13 pm »


               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

 
               
               

               
            

Legacy_eeriegeek

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +0/-0
Booting Players
« Reply #4 on: July 05, 2011, 04:38:56 am »


               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.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Booting Players
« Reply #5 on: July 05, 2011, 04:33:10 pm »


               

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