[system] Reboot Serveur

Répondre
Partager Rechercher
J'ai trouvé ce script permettant le reboot du serveur automatiquement, j'avoue ne pas comprendre absolument tout, c-a-d comment le mettre dans le module, mis a part le faite de l'inclure dans le on client leave ou enter.

Code PHP:

PHP:--------------------------------------------------------------------------------
///////////////////////////////////////////////////////////
// Script de reboot serveur, Par Rhyghar
// D'apres le script de de repos de Lucindrea
///////////////////////////////////////////////////////////
#include "aps_include"

void broadcast(string texte)
{
    
object oPC GetFirstPC();
    while(
oPC != OBJECT_INVALID){
        
SendMessageToPC(oPCtexte);
        
oPC GetNextPC();
    }
}


void Kick()
{
    
object oPC GetFirstPC();
    while(
oPC != OBJECT_INVALID){
        
BootPC(oPC);
        
oPC GetNextPC();
    }
}

void rebootsequence()
{
     
broadcast("Reboot Serveur dans une minute !!!");
     
broadcast("Sauvegarde des Personnages...");
     
ExportAllCharacters();
     
DelayCommand(5.0fbroadcast("Personnages sauvegardes..."));
     
DelayCommand(30.0fbroadcast("Reboot serveur dans 30 secondes..."));
     
DelayCommand(50.0fbroadcast("Reboot serveur dans 10 secondes..."));
     
DelayCommand(55.0fbroadcast("Reboot serveur dans 05 secondes..."));
     
DelayCommand(60.0fbroadcast("Ejection des joueur..."));
     
DelayCommand(62.0fKick());
     
DelayCommand(65.0fbroadcast("Reboot serveur..."));
     
DelayCommand(70.0fStartNewModule(GetModuleName()));


}

void main()
{
object oMod=GetModule();
string sModTag GetTag(oMod);

int A TRUE;

//First get the time last rested in yyyymmddhhmmss format
string sSQL "SELECT val FROM LastSlept WHERE tag='"+sModTag+"';";
SQLExecDirect(sSQL);
SQLFirstRow();
string sTimeSlept SQLGetData(1);
//SendMessageToAllDMs("last slept as string" + sTimeSlept);
if (sTimeSlept == "")
{
    
TRUE;
     
SQLExecDirect("SELECT NOW() + 0");
    
SQLFirstRow();
    
string sTimeNow SQLGetData(1);
    
SetPersistentString(oMod,sModTag,sTimeNow,0,"LastSlept");
}

sSQL "SELECT DateDiff('s', #"+sTimeSlept+"#, Now());";

SQLExecDirect(sSQL);
SQLFirstRow();
string difference SQLGetData(1);

int iDiff StringToInt(difference);

// 24 heures = 24*3600 secondes = 86400 secondes
if(abs(iDiff) > 86400)FALSE;

if (
A)
{
    return;
}else{
    
SQLExecDirect("SELECT NOW() + 0");
    
SQLFirstRow();
    
string sTimeNow SQLGetData(1);
    
// dump current time into database called LastSlept
    
SetPersistentString(oMod,sModTag,sTimeNow,0,"LastSlept");
    
WriteTimestampedLogEntry("reboot automatique serveur : "sTimeNow);
    
rebootsequence();

}

Si quelqu'un a mieux, ou pourrait m'expliquer comment il ce fractionne. Par ailleurs ce système n'alourdit pas un peut plus le serveur ?
déjà il faut un système externe de DB (au vu de la requête SQL ..), ensuite, on teste toutes les 6 secondes si on a dépassé la journée de lancement et si oui, on kick tout le monde en les prévenant et on reboot ..

bon, il y a plus simple, mais on n'échappe pas au système du OnHeartBeat si on veut que cela soit automatique ..
sinon, on peut avec un simple wand le faire assez facilement ..
*vient de reconnaitre son script*

alors en fait, a chaque fois quelqu'un quitte le module, le serveur verifie qu''une journée (86400 secondes) ne s'est pas écoulé. Si c'est la cas, il relance le module apres avoir sauvé les personnages et ejecté les joueurs.

Le script se place dans un OnClientLeave (ou OnclientEnter, ou bien OnHeartBeat). Sa reste bien moins lourd de le laisser en Onclient Leave (ou OnclientEnter).

La requette SQL sert a faire un DateDiff (calcul de temps écoulé entre deux dates) qui est tout de meme plus simple que de faire le calcul soi même. Là j'ai spécifié qu'il me renvoie la valeur en seconde.

Ah oui, c'est en effet a faire marcher avec NWNX car il permet de relancer un module qui plante. Là il n'y a pas de probleme car le serveur relancera le même module:
Code PHP:

StartNewModule(GetModuleName()); 

Mais comme je n'étais pas sûre que le processus soit effectivement détruit avec cette méthode, je faisais planter exprès le module en lui faisant lancer un module qui n'existe pas:
Code PHP:

StartNewModule("nnnnnnnnnnnnnn"); 

Voila !
__________________
..::Heavenlynet le net paradisiaque ::..
http://gw.heaven-ly.net/images/stories/divers/sigfg042.gif
Donc si je comprend bien, je copie ce script dans mon on client enter (par exemple), et je lui dis de charger un module que je n'ai pas ? ou je lui donne le Tag de mon module ?
Heu erreur de l'include, je dois faire comment ?

Une partie de ce script est le fameux include ? j'imagine que c'est celle qui commence par le void main ???
non, si je me rappelle bien, il suffit de le mettre dans un evenement sans toucher au script. Est-ce que tu as bien un script qui s'apelle "aps_include" dans ton module ?
Si ça n'est pas le cas, il se pourrait que tu n'aies pas bien installé NWNX.
__________________
..::Heavenlynet le net paradisiaque ::..
http://gw.heaven-ly.net/images/stories/divers/sigfg042.gif
je viens de faire un copier coller du code dans l'editeur et de le compiler. Il ne me fais pas d'erreur.

As-tu copié collé le script à l'interieur de la fonction main() que l'editeur crée par défaut ou bien as tu copié le code dans apres avoir supprimé cette fontion main vide que l'editeur donne lors de la création d'un nouveau script :
Code PHP:

void main()
{


Il faut la supprimer avant de tout coller.
__________________
..::Heavenlynet le net paradisiaque ::..
http://gw.heaven-ly.net/images/stories/divers/sigfg042.gif
Citation :
alors en fait, a chaque fois quelqu'un quitte le module, le serveur verifie qu''une journée (86400 secondes) ne s'est pas écoulé. Si c'est la cas, il relance le module apres avoir sauvé les personnages et ejecté les joueurs.
un simple "DelayCommand" ne serait il pas plus interessant ?
Citation :
Provient du message de Azrael07
un simple "DelayCommand" ne serait il pas plus interessant ?
Ah tiens, c'est vrai que ça se vaut, si tu met un delaycommand ca veut dire qu'il y aura toujours un compteur se decomptera dans le module. Avec le OnclientLeave, cela ne se fera que lorsque quelqu'un quittera la partie.

Maintenant, il peut se passer plusieurs heures sans que quelqu'un ne quitte le module ou bien il peuvent tous partir d'un coup ce qui rappellera plusieur fois le script. Je ne sais pas ce qui est le plus avantageux, c'est juste que je l'ai fait tel que je l'ai pensé *n'aime pas trop les delaycommand de plusieurs heures (bien que si ca trouve ca marche bien aussi)*
__________________
..::Heavenlynet le net paradisiaque ::..
http://gw.heaven-ly.net/images/stories/divers/sigfg042.gif
Citation :
Provient du message de Rhyghar
je viens de faire un copier coller du code dans l'editeur et de le compiler. Il ne me fais pas d'erreur.

As-tu copié collé le script à l'interieur de la fonction main() que l'editeur crée par défaut ou bien as tu copié le code dans apres avoir supprimé cette fontion main vide que l'editeur donne lors de la création d'un nouveau script :
Code PHP:

void main()
{


Il faut la supprimer avant de tout coller.
Oui j'utilise les HCR donc je lais mis en fin de script des HCR, et ca marche toujours pas, il n'y a pas de void main() sauf dans ton script...
Citation :
Provient du message de ruru666
Oui j'utilise les HCR donc je lais mis en fin de script des HCR, et ca marche toujours pas, il n'y a pas de void main() sauf dans ton script...
*a du mal a comprendre*

tu pourrais poster ici tout ce que tu as dans OnClientLeave ?
__________________
..::Heavenlynet le net paradisiaque ::..
http://gw.heaven-ly.net/images/stories/divers/sigfg042.gif
Code PHP:

// This script goes in OnClientEnter in Module Properties - Events
// It checks to see if they have a Death Amulet on them, and if so
// It sets thier player state to Dead and rekills them.
#include "hc_inc"
#include "hc_inc_on_enter"
#include "hc_cdrop_on_ent"
#include "hc_text_enter"
#include "hc_inc_remeff"
#include "hc_inc_rezpen"
#include "hc_inc_htf"
#include "hc_inc_timecheck"
// hcr3 7/18/2003
#include "hc_id"
// hcr3 7/27/2003
#include "hc_inc_persist"
#include "i_tagtests"
// hcr3.1
#include "crr_subrace_hc_i"


// hcr3 if not restarted kill them.
// 7/25/2003 fixed to kill to create raisable corpse even on restart for PW.
// 8/3/2003 fix for entering while dying.
void CheckFugue(object oPC){

         if (
GetTag(GetArea(oPC)) != "FuguePlane")
         {
           if (!
GetLocalInt(oPC"ENTERED"))
           {
              
SetLocalInt(oPC"GRAVEYARD"TRUE);
           }
           
SetLocalInt(oPC,"LOGINDEATH",1);
           
effect eDeath EffectDeath(FALSEFALSE);
           
ApplyEffectToObject(DURATION_TYPE_INSTANTeDeathoPC);
         }
}

// hcr3 added new function based on hc_defaults setting.
//Allows prcs if the player already has it.
void prcunset(object oPC)
{
//Unset if PrC in second clot
int nClass GetClassByPosition(2oPC);
switch(
nClass)
{
    case(
CLASS_TYPE_ASSASSIN):
        
DeleteLocalInt(oPC"X1_AllowAsasin");
        break;
    case(
CLASS_TYPE_ARCANE_ARCHER):
        
DeleteLocalInt(oPC"X1_AllowArcher");
        break;
    case(
CLASS_TYPE_BLACKGUARD):
        
DeleteLocalInt(oPC"X1_AllowBlkGrd");
        break;
    case(
CLASS_TYPE_HARPER):
        
DeleteLocalInt(oPC"X1_AllowHarper");
        break;
    case(
CLASS_TYPE_SHADOWDANCER):
        
DeleteLocalInt(oPC"X1_AllowShadow");
        break;
    default:
        break;
}
//End switch(nClass) for 2nd slot
//Unset if PrC in third clot
nClass GetClassByPosition(3oPC);
switch(
nClass)
{
    case(
CLASS_TYPE_ASSASSIN):
        
DeleteLocalInt(oPC"X1_AllowAsasin");
        break;
    case(
CLASS_TYPE_ARCANE_ARCHER):
        
DeleteLocalInt(oPC"X1_AllowArcher");
        break;
    case(
CLASS_TYPE_BLACKGUARD):
        
DeleteLocalInt(oPC"X1_AllowBlkGrd");
        break;
    case(
CLASS_TYPE_HARPER):
        
DeleteLocalInt(oPC"X1_AllowHarper");
        break;
    case(
CLASS_TYPE_SHADOWDANCER):
        
DeleteLocalInt(oPC"X1_AllowShadow");
        break;
    default:
        return;
}
//End switch(nClass) for third slot
}//End void prcblock(object oPC)


void TakeHPs(object oTarget)
{
effect eDam=EffectDamage(GetCurrentHitPoints(oTarget)-1);
ApplyEffectToObject(DURATION_TYPE_INSTANT ,eDam ,oTarget);
}

void HCRBoot(object oPCstring sReason)
{
    
SendMessageToPC(oPC,sReason);
    
DelayCommand(10.0,BootPC(oPC));
}

location GetSavedLocation(object oPC)
{
    
location lLoc GetPersistentLocation(oPC"PV_START_LOCATION");

    if (
GetAreaFromLocation(lLoc) == OBJECT_INVALID)
        
SetLocalInt(oPC"TMP_VALID_SPAWN"0);
    else
        
SetLocalInt(oPC"TMP_VALID_SPAWN"1);

    return 
lLoc;
}

// hcr3 deleted PWDB_placehchar function caused quirky behavior and didnt work correctly.
void main()
{
  if(!
preEvent()) return;
  
dropCrpse();
  
object oPC GetEnteringObject();
  
// hcr3.1
  
if (GetLocalInt(GetModule(), "SUBRACES"))
      
crr_SubraceHCRenteroPC );
  
// party rest code.
  
SetLocalInt(oPC"RestOption"0);
  
string sCDK=GetPCPlayerName(oPC);
  
string sID=GetName(oPC)+GetPCPlayerName(oPC);
  
// hcr3 7/21/2003
  // set sID so it will always be available.
  
SetLocalString(oPC"sID"sID);
  
SetPlotFlag(oPC,FALSE);
  
int nPKT=GetLocalInt(oMod,"PKTRACKER");
  
int nDM=GetIsDM(oPC);
  
// hcr3 check for allowed prestige classes
  
if (!nDM)
  {
   
//Prep all classes as in hc_defaults
   
if (!GetLocalInt(oMod"ASSASIN")
       && !
GetPersistentInt(oMod"ASSASIN"+sID))
     
SetLocalInt(oPC"X1_AllowAsasin"1);
   if (!
GetLocalInt(oMod"ARCHER")
       && !
GetPersistentInt(oMod"ARCHER"+sID))
     
SetLocalInt(oPC"X1_AllowArcher"1);
   if (!
GetLocalInt(oMod"BLKGUARD")
       && !
GetPersistentInt(oMod"BLKGUARD"+sID))
     
SetLocalInt(oPC"X1_AllowBlkGrd"1);
   if (!
GetLocalInt(oMod"HARPER")
       && !
GetPersistentInt(oMod"HARPER"+sID))
     
SetLocalInt(oPC"X1_AllowHarper"1);
   if (!
GetLocalInt(oMod"SHADOW")
       && !
GetPersistentInt(oMod"SHADOW"+sID))
     
SetLocalInt(oPC"X1_AllowShadow"1);
   
prcunset(oPC);
  }

  if(
nPKT)
  {
    if(
GetPersistentInt(oMod,"PKCOUNT"+sCDK)>nPKT)
    {
        
SendMessageToAllDMs(sCDK+DMBOOTPK);
        
HCRBoot(oPC,PCBOOTPK);
        
postEvent();
        return;
    }
  }
  
// hcr3 8/5/2003
  
string sCDKey GetPCPublicCDKey(oPC);
  if(
GetLocalInt(oMod,"SINGLECHARACTER")  && !nDM)
  {
     
string sRegChar=GetPersistentString(oMod"SINGLECHARACTER"sCDKey);
     if(
sRegChar != "" && sRegChar != GetName(oPC))
     {
        
HCRBoot(oPC,SINGLEBOOT+sRegChar);
        
postEvent();
        return;
     }
     else
     {
        
SetPersistentString(oMod"SINGLECHARACTER"sCDKeyGetName(oPC));
        
SendMessageToPC(oPC,SINGLEREG);
     }

  }
  
// 5.5 added code to not count DMs as multichars
  
else if (GetLocalInt(oMod"MULTICHAR") > && !nDM)
  {
    
string sRegChar;
    
int nCount =1;
    
int nReg FALSE;
    
int nNum GetLocalInt(oMod"MULTICHAR");
    for (
nCountnCount <= nNumnCount++)
    {
        
sRegChar=GetPersistentString(oMod"MULTICHAR"IntToString(nCount)+ sCDKey);
        if (
sRegChar == "")
        {
                   
SetPersistentString(oMod"MULTICHAR"IntToString(nCount)+ sCDKeyGetName(oPC));
                   
SendMessageToPC(oPC,SINGLEREG);
                   
nCount nNum+1;
                   
nReg TRUE;
        }
        else
         if (
sRegChar == GetName(oPC))
         {
            
nReg TRUE;
            
nCount nNum+1;
         }
    }
    if (!
nReg)
    {
        
HCRBoot(oPC,MULTIBOOT);
        
postEvent();
        return;
    }
  }
  if(
GetPersistentInt(oMod,"BANNED"+sCDK))
  {
    
HCRBoot(oPCBANNED);
    
postEvent();
    return;
  }
  if(
GetLocalInt(oMod,"LOCKED") && !nDM)
  {
    
HCRBoot(oPC,LOCKED);
    
postEvent();
    return;
  }
  if(
GetLocalInt(oMod,"DMRESERVE"))
  {
    
int nC;
    
object oPlayers=GetFirstPC();
    if(!
nDM)
    {
        while(
GetIsObjectValid(oPlayers))
        {
            if(!
GetIsDM(oPlayers)) nC++;
            
oPlayers=GetNextPC();
        }
    }
    if(
nC GetLocalInt(oMod,"DMRESERVE") && nDM==FALSE)
    {
        
HCRBoot(oPC,DMRES);
        
postEvent();
        return;
    }
  }
  if(!
GetLocalInt(oMod,"HCRREAD"))
  {
    
SendMessageToPC(oPC,NOHCRENABLED);
    return;
  }
  
int nGiveLevel=GetLocalInt(oMod,"GIVELEVEL");
  if(
GetLocalInt(oMod,"STORESYSTEM"))
  {
    if(
GetIsPC(oPC) && !(GetXP(oPC)) && !nDM)
    {
        
string  STORE_NAME      "NewbieMerchant";

//If you want everyone to have the same amount of starting gold, modify the
//lines below
//      int     STARTING_GOLD = 150;
        
int     STARTING_GOLD=2000;
        
int     PLAYER_STRIPS   TRUE;

// Giving PC its starting gold.
        
if(nGiveLevel && STARTING_GOLD==0)
        {
            switch (
nGiveLevel)
            {
                case 
2:  STARTING_GOLD 900; break;
                case 
3:  STARTING_GOLD 2700; break;
                case 
4:  STARTING_GOLD 5400; break;
                case 
5:  STARTING_GOLD 9000; break;
                case 
6:  STARTING_GOLD 13000; break;
                case 
7:  STARTING_GOLD 19000; break;
                case 
8:  STARTING_GOLD 27000; break;
                case 
9:  STARTING_GOLD 36000; break;
                case 
10STARTING_GOLD 49000; break;
                case 
11STARTING_GOLD 66000; break;
                case 
12STARTING_GOLD 88000; break;
                case 
13STARTING_GOLD 110000; break;
                case 
14STARTING_GOLD 150000; break;
                case 
15STARTING_GOLD 200000; break;
                case 
16STARTING_GOLD 260000 ; break;
                case 
17STARTING_GOLD 340000; break;
                case 
18STARTING_GOLD 440000; break;
                case 
19STARTING_GOLD 580000; break;
                case 
20STARTING_GOLD 760000; break;
            }
        }
        if(!
STARTING_GOLD)
        {
            if(
GetLevelByClass(CLASS_TYPE_BARBARIANoPC)) STARTING_GOLD=d4(4)*10;
            else if(
GetLevelByClass(CLASS_TYPE_BARDoPC)) STARTING_GOLD=d4(4)*10;
            else if(
GetLevelByClass(CLASS_TYPE_CLERICoPC)) STARTING_GOLD=d4(5)*10;
            else if(
GetLevelByClass(CLASS_TYPE_DRUIDoPC)) STARTING_GOLD=d4(2)*10;
            else if(
GetLevelByClass(CLASS_TYPE_FIGHTERoPC)) STARTING_GOLD=d4(6)*10;
            else if(
GetLevelByClass(CLASS_TYPE_MONKoPC)) STARTING_GOLD=d4(5);
            else if(
GetLevelByClass(CLASS_TYPE_PALADINoPC)) STARTING_GOLD=d4(6)*10;
            else if(
GetLevelByClass(CLASS_TYPE_RANGERoPC)) STARTING_GOLD=d4(6)*10;
            else if(
GetLevelByClass(CLASS_TYPE_ROGUEoPC)) STARTING_GOLD=d4(5)*10;
            else if(
GetLevelByClass(CLASS_TYPE_SORCERERoPC)) STARTING_GOLD=d4(3)*10;
            else if(
GetLevelByClass(CLASS_TYPE_WIZARDoPC)) STARTING_GOLD=d4(3)*10;
            else 
STARTING_GOLD=d4(4)*10;
        }
        
AssignCommand(oPCTakeGoldFromCreature(GetGold(oPC), oPCTRUE));
        
// hcr3.1
        
if( !crr_SubraceHCRstartGoldoPC ) || !GetLocalInt(GetModule(), "SUBRACES"))
            
AssignCommand(oPCDelayCommand(2.0GiveGoldToCreature(oPCSTARTING_GOLD)));
        if (
PLAYER_STRIPS)
        {

// Removing PC's equipment.
            // hcr3.1 added nodrop checking.
            
object oGear GetItemInSlot(INVENTORY_SLOT_ARMSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BELToPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BOLTSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BOOTSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
//hcr3.1 took out stripping chest slot pcs get free set of clothes.
            //oGear = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
            //if(GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                //DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_CLOAKoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_HEADoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_LEFTHANDoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_LEFTRINGoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_NECKoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_RIGHTHANDoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_RIGHTRINGoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_ARROWSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BOLTSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BULLETSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
        }

// Removing PC's inventory.
        // hcr3.1 added nodrop checking.
        
object oStuff GetFirstItemInInventory(oPC);
        while(
GetIsObjectValid(oStuff) && !GetIsNoDrop(oStuff))
        {
            
DestroyObject(oStuff);
            
oStuff GetNextItemInInventory(oPC);
        }

// Greet PC.

        
DelayCommand(3.0SendMessageToPC(oPCNOGOLD IntToString(STARTING_GOLD) + " gp."));
        
DelayCommand(3.0SendMessageToPC(oPCHCRINTRO));

// Taking PC shopping.

    
}
  }
  if (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM")))
  {
    
effect eImmune EffectImmunity(IMMUNITY_TYPE_TRAP);
    
ApplyEffectToObject(DURATION_TYPE_PERMANENTeImmuneoPC);
  }

  if(
GetHitDice(oPC)< nGiveLevel &&
        
nGiveLevel 1)
  {
    
SendMessageToPC(oPCNEWLEVEL+
        
IntToString(nGiveLevel));
    
int nNewXP= (nGiveLevel * (nGiveLevel-1)) / 1000;
    
DelayCommand(2.0,SetXP(oPC,nNewXP));
    
DelayCommand(2.1,SetPersistentInt(oPC,"ALLOWLEVEL",1));
  }
    if(
GetLevelByClass(CLASS_TYPE_RANGER,oPC) &&
        
GetIsObjectValid(GetItemPossessedBy(oPC,"TrackerTool"))==FALSE)
           
CreateItemOnObject("trackertool"oPC);
// Give Paladins their tools that simulate missing abilities
    
if(GetLevelByClass(CLASS_TYPE_PALADIN,oPC)>&&
        
GetIsObjectValid(GetItemPossessedBy(oPC,"hc_palbadgecour"))==FALSE)
           
CreateItemOnObject("paladinsbadgeofc"oPC);
    if(
GetLevelByClass(CLASS_TYPE_PALADIN,oPC) &&
        
GetIsObjectValid(GetItemPossessedBy(oPC,"hc_paladinsymb"))==FALSE)
           
CreateItemOnObject("paladinsholysymb"oPC);
// hcr3 Give PC healing ability as per 3e.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"HC_HEAL_NODROP")))
         
CreateItemOnObject("healability"oPC);

// hcr3
/***********      HCRHELPER WANDS      *********/

/*** DM WANDS ***/
// Give PC DM's a wand version of the HCR helper
    
if(sCDK != "" && sCDK==GetPersistentString(oMod,"PLAYERDM"))
    {
        if(
GetIsObjectValid(GetItemPossessedBy(oPC,"HCRHelpwand"))==FALSE)
            
CreateItemOnObject("HCRHelpwand"oPC);
    }
// Give DM's a HCR Helper in inventory
    
if(GetIsObjectValid(GetItemPossessedBy(oPC,"HCRHelper"))==FALSE &&
      (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           
CreateItemOnObject("HCRHelper"oPC);

/***********      DMHELPER WANDS       *********/

/*** PLAYER CHARACTER WANDS ***/
// Give PC's an EmoteWand if using the DMHelper set.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"EmoteWand")))
         
CreateItemOnObject("emotewand"oPC);
// set emote wand to plot 5.4.1(bug fix)
    
object oItem GetItemPossessedBy(oPC"EmoteWand" );
    if (
GetIsObjectValid(oItem))
      
SetPlotFlag(oItemTRUE);
/*** DM WANDS ***/
// Give DM's a FXWand in inventory
    
if(GetIsObjectValid(GetItemPossessedBy(oPC,"WandOfFX"))==FALSE &&
       (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           
CreateItemOnObject("WandOfFX"oPC);
// Give DM's a DMHelper in inventory
    
if(GetIsObjectValid(GetItemPossessedBy(oPC,"DMsHelper"))==FALSE &&
       (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           
CreateItemOnObject("DMsHelper"oPC);

/*********** NEW DMFI WAND PACKAGE 3.0 *********/

/*** PLAYER CHARACTER WANDS ***/
// Give PC's an EmoteWand if using the DMFIHelper set.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_pc_emote")))
         
CreateItemOnObject("dmfi_pc_emote"oPC);
// Give PC's a Dicebag if using the DMFIHelper set.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_pc_dicebag")))
         
CreateItemOnObject("dmfi_pc_dicebag"oPC);
// Give PC's a Follow wand if using the DMFIHelper set.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_pc_follow")))
         
CreateItemOnObject("dmfi_pc_follow"oPC);

/*** DM WANDS ***/
/*
// hcr3
// remarked out because the onering does all this and creates less clutter.
// if you want individual wands instead unremark the wands you want to use.
// Give DM's a DMFI Wand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_dmw"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_dmw", oPC);
// Give DM's a DMFI FXWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_fx"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_fx", oPC);
// Give DM's a DMFI SoundWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_sound"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_sound", oPC);
// Give DM's a DMFI AfflictWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_afflict"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_afflict", oPC);
// Give DM's a DMFI XPWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_xp"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_xp", oPC);
// Give DM's a DMFI MusicWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_music"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_music", oPC);
// Give DM's a DMFI NPC Control wand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_faction"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_faction", oPC);
*/
// Give DM's a the one ring to be able to use all wand function in thier inventory
    
if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_onering"))==FALSE &&
       (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           
CreateItemOnObject("dmfi_onering"oPC);

/*********** END OF WAND PACKAGES *********/

// Give new PC's some food.
    
if(GetLocalInt(oMod,"FOODSYSTEM") || GetLocalInt(oMod,"HUNGERSYSTEM"))
    {
        if(!
GetXP(oPC) && !nDM)
             
CreateItemOnObject("FoodRation"oPC);
    }
// Give new PC's a bedroll for the rest system
    
if(GetLocalInt(oMod,"BEDROLLSYSTEM"))
    {
        if(!
GetXP(oPC) && !nDM)
            if(
GetIsObjectValid(GetItemPossessedBy(oPC,"bedroll"))==FALSE)
                
CreateItemOnObject("bedroll"oPC);
    }
// Start of playerstate checking
    // hcr3 7/25/2003
    // return if a dm.
    
if (nDM)
       return;
    
// hcr3 7/27/2003
    // persistence code
    // strip player corpses on enter.
    // could happen if server restarts while carrying one.
    
object oPcorpse GetFirstItemInInventory(oPC);
    while (
GetIsObjectValid(oPcorpse))
    {
       if (
GetResRef(oPcorpse) == "playercorpse")
           
DestroyObject(oPcorpse);
       
oPcorpse GetNextItemInInventory(oPC);
    }
    
int nPersist GetLocalInt(oMod"PERSIST");
    
// hcr3 only do if deathsystem is on.
    
if (GetLocalInt(oMod"DEATHSYSTEM"))
    {
     if (
nPersist && !GetLocalInt(oPC"ENTERED"))
        
// hcr3 8/12/2003
        
HCLoadDB(sIDoPC);

     
int nCurState=GPS(oPC);
     
//SendMessageToPC(oPC, "STATE"+IntToString(nCurState));
     
int nHP=GetPersistentInt(oMod,"LastHP"+GetName(oPC)+sCDK);
     
int nCHP=GetCurrentHitPoints(oPC);
     
// hcr3 8/12/2003 fix changed to limbo and not bleedsystem.
     
if(GetLocalInt(oMod,"LIMBO"))
     {
          if (
nCurState==PWS_PLAYER_STATE_RESURRECTED ||
          
nCurState==PWS_PLAYER_STATE_RESTRUE ||
          
nCurState==PWS_PLAYER_STATE_RAISEDEAD)
       {
          
RemoveEffects(oPC);
          if(
GetItemPossessedBy(oPC,"fuguerobe")!=OBJECT_INVALID)
              
DestroyObjectGetItemPossessedBy(oPC,"fuguerobe"));
          if(
nCurState!=PWS_PLAYER_STATE_RESTRUE &&
             
GetLocalInt(oMod,"REZPENALTY"))
             
DelayCommand(1.0hcRezPenalty(oPC));
          
// hcr3 7/27/2003
          // if not entered then move to graveyard.
          
if (!GetLocalInt(oPC"ENTERED"))
          {
             
location lGrave GetLocation(GetObjectByTag("GraveYard"));
             
DelayCommand(2.5AssignCommand(oPCJumpToLocation(lGrave)));
          }
          if(
nCurState==PWS_PLAYER_STATE_RAISEDEAD)
          {
             if( 
GetLocalInt(oMod,"REZPENALTY") && GetIsPC(oPC))
                
DelayCommand(2.0TakeHPs(oPC));
          }
          
SPS(oPC,PWS_PLAYER_STATE_ALIVE);
          
location lWhere=GetPersistentLocation(oMod,"RESLOC"+GetName(oPC)+sCDK);
          
DelayCommand(4.0,AssignCommand(oPC,JumpToLocation(lWhere)));
          
//DeletePersistentLocation(oMod, "RESLOC"+GetName(oPC)+sCDK);
       
}
       
// changed if else logic to fix bug in persistent world death restart
       
else if(GetItemPossessedBy(oPC,"fuguerobe")!=OBJECT_INVALID &&
               
nCurState==PWS_PLAYER_STATE_ALIVE)
       {
         
DestroyObject(GetItemPossessedBy(oPC"fuguerobe"));
         if(
GetLocalInt(oMod,"DEATHOVERREBOOT") )
         {
            
//effect eDeath = EffectDeath(FALSE, FALSE);
            //hcr3 7/25/2003 took out delay
            // set location fix.
            // 8/12/2003 fix for fugue check.
            // hcr3.1 shortened delay a tad
            
DelayCommand(4.5CheckFugue(oPC));
         }

       }
       else if(
nCurState==PWS_PLAYER_STATE_ALIVE)
       {
         if(
nHP && nCHP>nHP)
         {

            
// 8/3/2003 fix for fugue check.
            
SetLocalInt(oPC,"LOGINDEATH",1);
            
effect eDam=EffectDamage(nCHP-nHP);
            
DelayCommand(3.0,ApplyEffectToObject(DURATION_TYPE_INSTANTeDamoPC));
            
GetPersistentLocation(oMod,"RESLOC"+GetName(oPC)+sCDK);
         }
       }
       
// raised this if statement above the following one added robe code
       // hcr3 8/13/2003 fix for player not being killed on reenter from dying.
       
else
       {

               
// hcr3.1 changed delay.
               
if(GetLocalInt(oMod,"DEATHOVERREBOOT") )
               {
                  
effect eDam=ExtraordinaryEffect(EffectParalyze());
                  
ApplyEffectToObject(DURATION_TYPE_TEMPORARYeDamoPC8.0);
                  
DelayCommand(8.5CheckFugue(oPC));
               }
       }
     }
     else if(
GetLocalInt(oMod,"DEATHSYSTEM") )
     {
        
SetLocalInt(oPC,"LOGINDEATH",1);
        
effect eDeath EffectDeath(FALSEFALSE);
        if(
nCurState == PWS_PLAYER_STATE_DEAD)
            
ApplyEffectToObject(DURATION_TYPE_INSTANTeDeathoPC);
     }
     
// hcr3 7/25/2003 remarked out due to quirky behavior on enter.
     /*if(!GetLocalInt(oMod,"PRIORTHISREBOOT"+sCDK+GetName(oPC)))
     {
        if(nCurState!=PWS_PLAYER_STATE_DEAD)
            DelayCommand(5.0,PWDB_PlaceCharacter(oPC));
        SetLocalInt(oMod,"PRIORTHISREBOOT"+sCDK+GetName(oPC),1);
     }*/
    
}// end if deathsystem

    
InitPCHTFLevels(oPC);

    if(!(
GetXP(oPC)))
        
SetXP(oPC1);
    
// Send a login message to all players if one exists
    
if(GetLocalString(oMod,"LOGINMESSAGE") != "NONE")
        
SendMessageToPC(oPC,GetLocalString(oMod,"LOGINMESSAGE"));
    
// check to see if the pc has entered before. if so run strip talents.
    // hcr3 7/25/2003
    // changed to local no longer need persistent var.
    
if(GetLocalInt(oMod,"DECONENTER"))
      if (
GetLocalInt(oPC"ENTERED"))
         
ExecuteScript"hc_strip_talents"GetEnteringObject());
    
// hcr3.1 added delay.
    
DelayCommand(10.0SetLocalInt(oPC"ENTERED"TRUE));
    
postEvent();
}

PHP:--------------------------------------------------------------------------------
///////////////////////////////////////////////////////////
// Script de reboot serveur, Par Rhyghar
// D'apres le script de de repos de Lucindrea
///////////////////////////////////////////////////////////
#include "aps_include"

void broadcast(string texte)
{
    
object oPC GetFirstPC();
    while(
oPC != OBJECT_INVALID){
        
SendMessageToPC(oPCtexte);
        
oPC GetNextPC();
    }
}


void Kick()
{
    
object oPC GetFirstPC();
    while(
oPC != OBJECT_INVALID){
        
BootPC(oPC);
        
oPC GetNextPC();
    }
}

void rebootsequence()
{
     
broadcast("Reboot Serveur dans une minute !!!");
     
broadcast("Sauvegarde des Personnages...");
     
ExportAllCharacters();
     
DelayCommand(5.0fbroadcast("Personnages sauvegardes..."));
     
DelayCommand(30.0fbroadcast("Reboot serveur dans 30 secondes..."));
     
DelayCommand(50.0fbroadcast("Reboot serveur dans 10 secondes..."));
     
DelayCommand(55.0fbroadcast("Reboot serveur dans 05 secondes..."));
     
DelayCommand(60.0fbroadcast("Ejection des joueur..."));
     
DelayCommand(62.0fKick());
     
DelayCommand(65.0fbroadcast("Reboot serveur..."));
     
DelayCommand(70.0fStartNewModule(GetModuleName()));


}

void main()
{
object oMod=GetModule();
string sModTag GetTag(oMod);

int A TRUE;

//First get the time last rested in yyyymmddhhmmss format
string sSQL "SELECT val FROM LastSlept WHERE tag='"+sModTag+"';";
SQLExecDirect(sSQL);
SQLFirstRow();
string sTimeSlept SQLGetData(1);
//SendMessageToAllDMs("last slept as string" + sTimeSlept);
if (sTimeSlept == "")
{
    
TRUE;
     
SQLExecDirect("SELECT NOW() + 0");
    
SQLFirstRow();
    
string sTimeNow SQLGetData(1);
    
SetPersistentString(oMod,sModTag,sTimeNow,0,"LastSlept");
}

sSQL "SELECT DateDiff('s', #"+sTimeSlept+"#, Now());";

SQLExecDirect(sSQL);
SQLFirstRow();
string difference SQLGetData(1);

int iDiff StringToInt(difference);

// 24 heures = 24*3600 secondes = 86400 secondes
if(abs(iDiff) > 86400)FALSE;

if (
A)
{
    return;
}else{
    
SQLExecDirect("SELECT NOW() + 0");
    
SQLFirstRow();
    
string sTimeNow SQLGetData(1);
    
// dump current time into database called LastSlept
    
SetPersistentString(oMod,sModTag,sTimeNow,0,"LastSlept");
    
WriteTimestampedLogEntry("reboot automatique serveur : "sTimeNow);
    
rebootsequence();

}

Et je sais pas si c'est toi qui a mal compris ou moi qui m'exprime mal
Citation :
Ah tiens, c'est vrai que ça se vaut, si tu met un delaycommand ca veut dire qu'il y aura toujours un compteur se decomptera dans le module. Avec le OnclientLeave, cela ne se fera que lorsque quelqu'un quittera la partie.
bien si le DelayCommand est fait comme une décrémentation tout les 0.01 secondes (ou quelque chose comme ca) de touts les évenements enregistré par la fonction, c'est clair que ca n'est pas interessant.

A mon avis, c'est plutot organisé par une liste chainée, le premier élément étant celui qui se déclanchera le premier, qui pointe vers celui qui se déclanchera ensuite, et ainsi de suite jusqu'au dernier. Chaques passage incrémente la variable temporelle, et celle si est comparée au temps. Si le temps du premier est dépassé, on l'execute et on regarde le second, et ainsi de suite jusqu'a ce qu'on tombe sur un évenemnt qu'il est trop tot pour effectuer.

Si c'est fait comme ca, il est clair que c'est beaucoup plus interessant, plus précis, et plus esthetique.

Bon après, on parle la de quelques microsecondes, mais.... j'ai l'esprit pointilleux :P
Voila, essaye ça.

Maintenant, si ca marche c'est bien, mais si ca marche pas, ton OnClientEnter est deja bien rempli, je serais toi, je mettrait le script de repos dans le onclientleave.
PS: n'oublies pas de sauvegarder ton script avant toute modification

Code PHP:

// This script goes in OnClientEnter in Module Properties - Events
// It checks to see if they have a Death Amulet on them, and if so
// It sets thier player state to Dead and rekills them.
#include "hc_inc"
#include "hc_inc_on_enter"
#include "hc_cdrop_on_ent"
#include "hc_text_enter"
#include "hc_inc_remeff"
#include "hc_inc_rezpen"
#include "hc_inc_htf"
#include "hc_inc_timecheck"
// hcr3 7/18/2003
#include "hc_id"
// hcr3 7/27/2003
#include "hc_inc_persist"
#include "i_tagtests"
// hcr3.1
#include "crr_subrace_hc_i"


/*******************************************
DEBUT MODIF REBOOT
*******************************************/

//Aps_include pour NWNX
#include "aps_include"


///////////////////////////////////////////////////////////
// Script de reboot serveur, Par Rhyghar
// D'apres le script de de repos de Lucindrea
///////////////////////////////////////////////////////////


void broadcast(string texte)
{
    
object oPC GetFirstPC();
    while(
oPC != OBJECT_INVALID){
        
SendMessageToPC(oPCtexte);
        
oPC GetNextPC();
    }
}


void Kick()
{
    
object oPC GetFirstPC();
    while(
oPC != OBJECT_INVALID){
        
BootPC(oPC);
        
oPC GetNextPC();
    }
}

void rebootsequence()
{
     
broadcast("Reboot Serveur dans une minute !!!");
     
broadcast("Sauvegarde des Personnages...");
     
ExportAllCharacters();
     
DelayCommand(5.0fbroadcast("Personnages sauvegardes..."));
     
DelayCommand(30.0fbroadcast("Reboot serveur dans 30 secondes..."));
     
DelayCommand(50.0fbroadcast("Reboot serveur dans 10 secondes..."));
     
DelayCommand(55.0fbroadcast("Reboot serveur dans 05 secondes..."));
     
DelayCommand(60.0fbroadcast("Ejection des joueur..."));
     
DelayCommand(62.0fKick());
     
DelayCommand(65.0fbroadcast("Reboot serveur..."));
     
DelayCommand(70.0fStartNewModule(GetModuleName()));


}

/*******************************************
DEBUT MODIF REBOOT
*******************************************/




// hcr3 if not restarted kill them.
// 7/25/2003 fixed to kill to create raisable corpse even on restart for PW.
// 8/3/2003 fix for entering while dying.
void CheckFugue(object oPC){

         if (
GetTag(GetArea(oPC)) != "FuguePlane")
         {
           if (!
GetLocalInt(oPC"ENTERED"))
           {
              
SetLocalInt(oPC"GRAVEYARD"TRUE);
           }
           
SetLocalInt(oPC,"LOGINDEATH",1);
           
effect eDeath EffectDeath(FALSEFALSE);
           
ApplyEffectToObject(DURATION_TYPE_INSTANTeDeathoPC);
         }
}

// hcr3 added new function based on hc_defaults setting.
//Allows prcs if the player already has it.
void prcunset(object oPC)
{
//Unset if PrC in second clot
int nClass GetClassByPosition(2oPC);
switch(
nClass)
{
    case(
CLASS_TYPE_ASSASSIN):
        
DeleteLocalInt(oPC"X1_AllowAsasin");
        break;
    case(
CLASS_TYPE_ARCANE_ARCHER):
        
DeleteLocalInt(oPC"X1_AllowArcher");
        break;
    case(
CLASS_TYPE_BLACKGUARD):
        
DeleteLocalInt(oPC"X1_AllowBlkGrd");
        break;
    case(
CLASS_TYPE_HARPER):
        
DeleteLocalInt(oPC"X1_AllowHarper");
        break;
    case(
CLASS_TYPE_SHADOWDANCER):
        
DeleteLocalInt(oPC"X1_AllowShadow");
        break;
    default:
        break;
}
//End switch(nClass) for 2nd slot
//Unset if PrC in third clot
nClass GetClassByPosition(3oPC);
switch(
nClass)
{
    case(
CLASS_TYPE_ASSASSIN):
        
DeleteLocalInt(oPC"X1_AllowAsasin");
        break;
    case(
CLASS_TYPE_ARCANE_ARCHER):
        
DeleteLocalInt(oPC"X1_AllowArcher");
        break;
    case(
CLASS_TYPE_BLACKGUARD):
        
DeleteLocalInt(oPC"X1_AllowBlkGrd");
        break;
    case(
CLASS_TYPE_HARPER):
        
DeleteLocalInt(oPC"X1_AllowHarper");
        break;
    case(
CLASS_TYPE_SHADOWDANCER):
        
DeleteLocalInt(oPC"X1_AllowShadow");
        break;
    default:
        return;
}
//End switch(nClass) for third slot
}//End void prcblock(object oPC)


void TakeHPs(object oTarget)
{
effect eDam=EffectDamage(GetCurrentHitPoints(oTarget)-1);
ApplyEffectToObject(DURATION_TYPE_INSTANT ,eDam ,oTarget);
}

void HCRBoot(object oPCstring sReason)
{
    
SendMessageToPC(oPC,sReason);
    
DelayCommand(10.0,BootPC(oPC));
}

location GetSavedLocation(object oPC)
{
    
location lLoc GetPersistentLocation(oPC"PV_START_LOCATION");

    if (
GetAreaFromLocation(lLoc) == OBJECT_INVALID)
        
SetLocalInt(oPC"TMP_VALID_SPAWN"0);
    else
        
SetLocalInt(oPC"TMP_VALID_SPAWN"1);

    return 
lLoc;
}

// hcr3 deleted PWDB_placehchar function caused quirky behavior and didnt work correctly.
void main()
{
/*******************************************
DEBUT MODIF REBOOT
*******************************************/


  
object oMod=GetModule();
  
string sModTag GetTag(oMod);

  
int A TRUE;

  
//First get the time last rested in yyyymmddhhmmss format
  
string sSQL "SELECT val FROM LastSlept WHERE tag='"+sModTag+"';";
  
SQLExecDirect(sSQL);
  
SQLFirstRow();
  
string sTimeSlept SQLGetData(1);
  
//SendMessageToAllDMs("last slept as string" + sTimeSlept);
  
if (sTimeSlept == "")
  {
      
TRUE;
      
SQLExecDirect("SELECT NOW() + 0");
      
SQLFirstRow();
      
string sTimeNow SQLGetData(1);
      
SetPersistentString(oMod,sModTag,sTimeNow,0,"LastSlept");
  }

  
sSQL "SELECT DateDiff('s', #"+sTimeSlept+"#, Now());";

  
SQLExecDirect(sSQL);
  
SQLFirstRow();
  
string difference SQLGetData(1);

  
int iDiff StringToInt(difference);

  
// 24 heures = 24*3600 secondes = 86400 secondes
  
if(abs(iDiff) > 86400)FALSE;

  if (
A)
  {
      return;
  }else{
      
SQLExecDirect("SELECT NOW() + 0");
      
SQLFirstRow();
      
string sTimeNow SQLGetData(1);
      
// dump current time into database called LastSlept
      
SetPersistentString(oMod,sModTag,sTimeNow,0,"LastSlept");
      
WriteTimestampedLogEntry("reboot automatique serveur : "sTimeNow);
      
rebootsequence();

  }

/*******************************************
FIN MODIF REBOOT
*******************************************/

  
if(!preEvent()) return;
  
dropCrpse();
  
object oPC GetEnteringObject();
  
// hcr3.1
  
if (GetLocalInt(GetModule(), "SUBRACES"))
      
crr_SubraceHCRenteroPC );
  
// party rest code.
  
SetLocalInt(oPC"RestOption"0);
  
string sCDK=GetPCPlayerName(oPC);
  
string sID=GetName(oPC)+GetPCPlayerName(oPC);
  
// hcr3 7/21/2003
  // set sID so it will always be available.
  
SetLocalString(oPC"sID"sID);
  
SetPlotFlag(oPC,FALSE);
  
int nPKT=GetLocalInt(oMod,"PKTRACKER");
  
int nDM=GetIsDM(oPC);
  
// hcr3 check for allowed prestige classes
  
if (!nDM)
  {
   
//Prep all classes as in hc_defaults
   
if (!GetLocalInt(oMod"ASSASIN")
       && !
GetPersistentInt(oMod"ASSASIN"+sID))
     
SetLocalInt(oPC"X1_AllowAsasin"1);
   if (!
GetLocalInt(oMod"ARCHER")
       && !
GetPersistentInt(oMod"ARCHER"+sID))
     
SetLocalInt(oPC"X1_AllowArcher"1);
   if (!
GetLocalInt(oMod"BLKGUARD")
       && !
GetPersistentInt(oMod"BLKGUARD"+sID))
     
SetLocalInt(oPC"X1_AllowBlkGrd"1);
   if (!
GetLocalInt(oMod"HARPER")
       && !
GetPersistentInt(oMod"HARPER"+sID))
     
SetLocalInt(oPC"X1_AllowHarper"1);
   if (!
GetLocalInt(oMod"SHADOW")
       && !
GetPersistentInt(oMod"SHADOW"+sID))
     
SetLocalInt(oPC"X1_AllowShadow"1);
   
prcunset(oPC);
  }

  if(
nPKT)
  {
    if(
GetPersistentInt(oMod,"PKCOUNT"+sCDK)>nPKT)
    {
        
SendMessageToAllDMs(sCDK+DMBOOTPK);
        
HCRBoot(oPC,PCBOOTPK);
        
postEvent();
        return;
    }
  }
  
// hcr3 8/5/2003
  
string sCDKey GetPCPublicCDKey(oPC);
  if(
GetLocalInt(oMod,"SINGLECHARACTER")  && !nDM)
  {
     
string sRegChar=GetPersistentString(oMod"SINGLECHARACTER"sCDKey);
     if(
sRegChar != "" && sRegChar != GetName(oPC))
     {
        
HCRBoot(oPC,SINGLEBOOT+sRegChar);
        
postEvent();
        return;
     }
     else
     {
        
SetPersistentString(oMod"SINGLECHARACTER"sCDKeyGetName(oPC));
        
SendMessageToPC(oPC,SINGLEREG);
     }

  }
  
// 5.5 added code to not count DMs as multichars
  
else if (GetLocalInt(oMod"MULTICHAR") > && !nDM)
  {
    
string sRegChar;
    
int nCount =1;
    
int nReg FALSE;
    
int nNum GetLocalInt(oMod"MULTICHAR");
    for (
nCountnCount <= nNumnCount++)
    {
        
sRegChar=GetPersistentString(oMod"MULTICHAR"IntToString(nCount)+ sCDKey);
        if (
sRegChar == "")
        {
                   
SetPersistentString(oMod"MULTICHAR"IntToString(nCount)+ sCDKeyGetName(oPC));
                   
SendMessageToPC(oPC,SINGLEREG);
                   
nCount nNum+1;
                   
nReg TRUE;
        }
        else
         if (
sRegChar == GetName(oPC))
         {
            
nReg TRUE;
            
nCount nNum+1;
         }
    }
    if (!
nReg)
    {
        
HCRBoot(oPC,MULTIBOOT);
        
postEvent();
        return;
    }
  }
  if(
GetPersistentInt(oMod,"BANNED"+sCDK))
  {
    
HCRBoot(oPCBANNED);
    
postEvent();
    return;
  }
  if(
GetLocalInt(oMod,"LOCKED") && !nDM)
  {
    
HCRBoot(oPC,LOCKED);
    
postEvent();
    return;
  }
  if(
GetLocalInt(oMod,"DMRESERVE"))
  {
    
int nC;
    
object oPlayers=GetFirstPC();
    if(!
nDM)
    {
        while(
GetIsObjectValid(oPlayers))
        {
            if(!
GetIsDM(oPlayers)) nC++;
            
oPlayers=GetNextPC();
        }
    }
    if(
nC GetLocalInt(oMod,"DMRESERVE") && nDM==FALSE)
    {
        
HCRBoot(oPC,DMRES);
        
postEvent();
        return;
    }
  }
  if(!
GetLocalInt(oMod,"HCRREAD"))
  {
    
SendMessageToPC(oPC,NOHCRENABLED);
    return;
  }
  
int nGiveLevel=GetLocalInt(oMod,"GIVELEVEL");
  if(
GetLocalInt(oMod,"STORESYSTEM"))
  {
    if(
GetIsPC(oPC) && !(GetXP(oPC)) && !nDM)
    {
        
string  STORE_NAME      "NewbieMerchant";

//If you want everyone to have the same amount of starting gold, modify the
//lines below
//      int     STARTING_GOLD = 150;
        
int     STARTING_GOLD=2000;
        
int     PLAYER_STRIPS   TRUE;

// Giving PC its starting gold.
        
if(nGiveLevel && STARTING_GOLD==0)
        {
            switch (
nGiveLevel)
            {
                case 
2:  STARTING_GOLD 900; break;
                case 
3:  STARTING_GOLD 2700; break;
                case 
4:  STARTING_GOLD 5400; break;
                case 
5:  STARTING_GOLD 9000; break;
                case 
6:  STARTING_GOLD 13000; break;
                case 
7:  STARTING_GOLD 19000; break;
                case 
8:  STARTING_GOLD 27000; break;
                case 
9:  STARTING_GOLD 36000; break;
                case 
10STARTING_GOLD 49000; break;
                case 
11STARTING_GOLD 66000; break;
                case 
12STARTING_GOLD 88000; break;
                case 
13STARTING_GOLD 110000; break;
                case 
14STARTING_GOLD 150000; break;
                case 
15STARTING_GOLD 200000; break;
                case 
16STARTING_GOLD 260000 ; break;
                case 
17STARTING_GOLD 340000; break;
                case 
18STARTING_GOLD 440000; break;
                case 
19STARTING_GOLD 580000; break;
                case 
20STARTING_GOLD 760000; break;
            }
        }
        if(!
STARTING_GOLD)
        {
            if(
GetLevelByClass(CLASS_TYPE_BARBARIANoPC)) STARTING_GOLD=d4(4)*10;
            else if(
GetLevelByClass(CLASS_TYPE_BARDoPC)) STARTING_GOLD=d4(4)*10;
            else if(
GetLevelByClass(CLASS_TYPE_CLERICoPC)) STARTING_GOLD=d4(5)*10;
            else if(
GetLevelByClass(CLASS_TYPE_DRUIDoPC)) STARTING_GOLD=d4(2)*10;
            else if(
GetLevelByClass(CLASS_TYPE_FIGHTERoPC)) STARTING_GOLD=d4(6)*10;
            else if(
GetLevelByClass(CLASS_TYPE_MONKoPC)) STARTING_GOLD=d4(5);
            else if(
GetLevelByClass(CLASS_TYPE_PALADINoPC)) STARTING_GOLD=d4(6)*10;
            else if(
GetLevelByClass(CLASS_TYPE_RANGERoPC)) STARTING_GOLD=d4(6)*10;
            else if(
GetLevelByClass(CLASS_TYPE_ROGUEoPC)) STARTING_GOLD=d4(5)*10;
            else if(
GetLevelByClass(CLASS_TYPE_SORCERERoPC)) STARTING_GOLD=d4(3)*10;
            else if(
GetLevelByClass(CLASS_TYPE_WIZARDoPC)) STARTING_GOLD=d4(3)*10;
            else 
STARTING_GOLD=d4(4)*10;
        }
        
AssignCommand(oPCTakeGoldFromCreature(GetGold(oPC), oPCTRUE));
        
// hcr3.1
        
if( !crr_SubraceHCRstartGoldoPC ) || !GetLocalInt(GetModule(), "SUBRACES"))
            
AssignCommand(oPCDelayCommand(2.0GiveGoldToCreature(oPCSTARTING_GOLD)));
        if (
PLAYER_STRIPS)
        {

// Removing PC's equipment.
            // hcr3.1 added nodrop checking.
            
object oGear GetItemInSlot(INVENTORY_SLOT_ARMSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BELToPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BOLTSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BOOTSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
//hcr3.1 took out stripping chest slot pcs get free set of clothes.
            //oGear = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
            //if(GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                //DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_CLOAKoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_HEADoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_LEFTHANDoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_LEFTRINGoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_NECKoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_RIGHTHANDoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_RIGHTRINGoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_ARROWSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BOLTSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
            
oGear GetItemInSlot(INVENTORY_SLOT_BULLETSoPC);
            if(
GetIsObjectValid(oGear) && !GetIsNoDrop(oGear))
                
DestroyObject(oGear);
        }

// Removing PC's inventory.
        // hcr3.1 added nodrop checking.
        
object oStuff GetFirstItemInInventory(oPC);
        while(
GetIsObjectValid(oStuff) && !GetIsNoDrop(oStuff))
        {
            
DestroyObject(oStuff);
            
oStuff GetNextItemInInventory(oPC);
        }

// Greet PC.

        
DelayCommand(3.0SendMessageToPC(oPCNOGOLD IntToString(STARTING_GOLD) + " gp."));
        
DelayCommand(3.0SendMessageToPC(oPCHCRINTRO));

// Taking PC shopping.

    
}
  }
  if (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM")))
  {
    
effect eImmune EffectImmunity(IMMUNITY_TYPE_TRAP);
    
ApplyEffectToObject(DURATION_TYPE_PERMANENTeImmuneoPC);
  }

  if(
GetHitDice(oPC)< nGiveLevel &&
        
nGiveLevel 1)
  {
    
SendMessageToPC(oPCNEWLEVEL+
        
IntToString(nGiveLevel));
    
int nNewXP= (nGiveLevel * (nGiveLevel-1)) / 1000;
    
DelayCommand(2.0,SetXP(oPC,nNewXP));
    
DelayCommand(2.1,SetPersistentInt(oPC,"ALLOWLEVEL",1));
  }
    if(
GetLevelByClass(CLASS_TYPE_RANGER,oPC) &&
        
GetIsObjectValid(GetItemPossessedBy(oPC,"TrackerTool"))==FALSE)
           
CreateItemOnObject("trackertool"oPC);
// Give Paladins their tools that simulate missing abilities
    
if(GetLevelByClass(CLASS_TYPE_PALADIN,oPC)>&&
        
GetIsObjectValid(GetItemPossessedBy(oPC,"hc_palbadgecour"))==FALSE)
           
CreateItemOnObject("paladinsbadgeofc"oPC);
    if(
GetLevelByClass(CLASS_TYPE_PALADIN,oPC) &&
        
GetIsObjectValid(GetItemPossessedBy(oPC,"hc_paladinsymb"))==FALSE)
           
CreateItemOnObject("paladinsholysymb"oPC);
// hcr3 Give PC healing ability as per 3e.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"HC_HEAL_NODROP")))
         
CreateItemOnObject("healability"oPC);

// hcr3
/***********      HCRHELPER WANDS      *********/

/*** DM WANDS ***/
// Give PC DM's a wand version of the HCR helper
    
if(sCDK != "" && sCDK==GetPersistentString(oMod,"PLAYERDM"))
    {
        if(
GetIsObjectValid(GetItemPossessedBy(oPC,"HCRHelpwand"))==FALSE)
            
CreateItemOnObject("HCRHelpwand"oPC);
    }
// Give DM's a HCR Helper in inventory
    
if(GetIsObjectValid(GetItemPossessedBy(oPC,"HCRHelper"))==FALSE &&
      (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           
CreateItemOnObject("HCRHelper"oPC);

/***********      DMHELPER WANDS       *********/

/*** PLAYER CHARACTER WANDS ***/
// Give PC's an EmoteWand if using the DMHelper set.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"EmoteWand")))
         
CreateItemOnObject("emotewand"oPC);
// set emote wand to plot 5.4.1(bug fix)
    
object oItem GetItemPossessedBy(oPC"EmoteWand" );
    if (
GetIsObjectValid(oItem))
      
SetPlotFlag(oItemTRUE);
/*** DM WANDS ***/
// Give DM's a FXWand in inventory
    
if(GetIsObjectValid(GetItemPossessedBy(oPC,"WandOfFX"))==FALSE &&
       (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           
CreateItemOnObject("WandOfFX"oPC);
// Give DM's a DMHelper in inventory
    
if(GetIsObjectValid(GetItemPossessedBy(oPC,"DMsHelper"))==FALSE &&
       (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           
CreateItemOnObject("DMsHelper"oPC);

/*********** NEW DMFI WAND PACKAGE 3.0 *********/

/*** PLAYER CHARACTER WANDS ***/
// Give PC's an EmoteWand if using the DMFIHelper set.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_pc_emote")))
         
CreateItemOnObject("dmfi_pc_emote"oPC);
// Give PC's a Dicebag if using the DMFIHelper set.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_pc_dicebag")))
         
CreateItemOnObject("dmfi_pc_dicebag"oPC);
// Give PC's a Follow wand if using the DMFIHelper set.
    
if(!GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_pc_follow")))
         
CreateItemOnObject("dmfi_pc_follow"oPC);

/*** DM WANDS ***/
/*
// hcr3
// remarked out because the onering does all this and creates less clutter.
// if you want individual wands instead unremark the wands you want to use.
// Give DM's a DMFI Wand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_dmw"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_dmw", oPC);
// Give DM's a DMFI FXWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_fx"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_fx", oPC);
// Give DM's a DMFI SoundWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_sound"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_sound", oPC);
// Give DM's a DMFI AfflictWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_afflict"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_afflict", oPC);
// Give DM's a DMFI XPWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_xp"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_xp", oPC);
// Give DM's a DMFI MusicWand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_music"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_music", oPC);
// Give DM's a DMFI NPC Control wand in inventory
    if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_faction"))==FALSE &&
       (nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           CreateItemOnObject("dmfi_faction", oPC);
*/
// Give DM's a the one ring to be able to use all wand function in thier inventory
    
if(GetIsObjectValid(GetItemPossessedBy(oPC,"dmfi_onering"))==FALSE &&
       (
nDM || (sCDK!="" && sCDK==GetPersistentString(oMod,"PLAYERDM"))))
           
CreateItemOnObject("dmfi_onering"oPC);

/*********** END OF WAND PACKAGES *********/

// Give new PC's some food.
    
if(GetLocalInt(oMod,"FOODSYSTEM") || GetLocalInt(oMod,"HUNGERSYSTEM"))
    {
        if(!
GetXP(oPC) && !nDM)
             
CreateItemOnObject("FoodRation"oPC);
    }
// Give new PC's a bedroll for the rest system
    
if(GetLocalInt(oMod,"BEDROLLSYSTEM"))
    {
        if(!
GetXP(oPC) && !nDM)
            if(
GetIsObjectValid(GetItemPossessedBy(oPC,"bedroll"))==FALSE)
                
CreateItemOnObject("bedroll"oPC);
    }
// Start of playerstate checking
    // hcr3 7/25/2003
    // return if a dm.
    
if (nDM)
       return;
    
// hcr3 7/27/2003
    // persistence code
    // strip player corpses on enter.
    // could happen if server restarts while carrying one.
    
object oPcorpse GetFirstItemInInventory(oPC);
    while (
GetIsObjectValid(oPcorpse))
    {
       if (
GetResRef(oPcorpse) == "playercorpse")
           
DestroyObject(oPcorpse);
       
oPcorpse GetNextItemInInventory(oPC);
    }
    
int nPersist GetLocalInt(oMod"PERSIST");
    
// hcr3 only do if deathsystem is on.
    
if (GetLocalInt(oMod"DEATHSYSTEM"))
    {
     if (
nPersist && !GetLocalInt(oPC"ENTERED"))
        
// hcr3 8/12/2003
        
HCLoadDB(sIDoPC);

     
int nCurState=GPS(oPC);
     
//SendMessageToPC(oPC, "STATE"+IntToString(nCurState));
     
int nHP=GetPersistentInt(oMod,"LastHP"+GetName(oPC)+sCDK);
     
int nCHP=GetCurrentHitPoints(oPC);
     
// hcr3 8/12/2003 fix changed to limbo and not bleedsystem.
     
if(GetLocalInt(oMod,"LIMBO"))
     {
          if (
nCurState==PWS_PLAYER_STATE_RESURRECTED ||
          
nCurState==PWS_PLAYER_STATE_RESTRUE ||
          
nCurState==PWS_PLAYER_STATE_RAISEDEAD)
       {
          
RemoveEffects(oPC);
          if(
GetItemPossessedBy(oPC,"fuguerobe")!=OBJECT_INVALID)
              
DestroyObjectGetItemPossessedBy(oPC,"fuguerobe"));
          if(
nCurState!=PWS_PLAYER_STATE_RESTRUE &&
             
GetLocalInt(oMod,"REZPENALTY"))
             
DelayCommand(1.0hcRezPenalty(oPC));
          
// hcr3 7/27/2003
          // if not entered then move to graveyard.
          
if (!GetLocalInt(oPC"ENTERED"))
          {
             
location lGrave GetLocation(GetObjectByTag("GraveYard"));
             
DelayCommand(2.5AssignCommand(oPCJumpToLocation(lGrave)));
          }
          if(
nCurState==PWS_PLAYER_STATE_RAISEDEAD)
          {
             if( 
GetLocalInt(oMod,"REZPENALTY") && GetIsPC(oPC))
                
DelayCommand(2.0TakeHPs(oPC));
          }
          
SPS(oPC,PWS_PLAYER_STATE_ALIVE);
          
location lWhere=GetPersistentLocation(oMod,"RESLOC"+GetName(oPC)+sCDK);
          
DelayCommand(4.0,AssignCommand(oPC,JumpToLocation(lWhere)));
          
//DeletePersistentLocation(oMod, "RESLOC"+GetName(oPC)+sCDK);
       
}
       
// changed if else logic to fix bug in persistent world death restart
       
else if(GetItemPossessedBy(oPC,"fuguerobe")!=OBJECT_INVALID &&
               
nCurState==PWS_PLAYER_STATE_ALIVE)
       {
         
DestroyObject(GetItemPossessedBy(oPC"fuguerobe"));
         if(
GetLocalInt(oMod,"DEATHOVERREBOOT") )
         {
            
//effect eDeath = EffectDeath(FALSE, FALSE);
            //hcr3 7/25/2003 took out delay
            // set location fix.
            // 8/12/2003 fix for fugue check.
            // hcr3.1 shortened delay a tad
            
DelayCommand(4.5CheckFugue(oPC));
         }

       }
       else if(
nCurState==PWS_PLAYER_STATE_ALIVE)
       {
         if(
nHP && nCHP>nHP)
         {

            
// 8/3/2003 fix for fugue check.
            
SetLocalInt(oPC,"LOGINDEATH",1);
            
effect eDam=EffectDamage(nCHP-nHP);
            
DelayCommand(3.0,ApplyEffectToObject(DURATION_TYPE_INSTANTeDamoPC));
            
GetPersistentLocation(oMod,"RESLOC"+GetName(oPC)+sCDK);
         }
       }
       
// raised this if statement above the following one added robe code
       // hcr3 8/13/2003 fix for player not being killed on reenter from dying.
       
else
       {

               
// hcr3.1 changed delay.
               
if(GetLocalInt(oMod,"DEATHOVERREBOOT") )
               {
                  
effect eDam=ExtraordinaryEffect(EffectParalyze());
                  
ApplyEffectToObject(DURATION_TYPE_TEMPORARYeDamoPC8.0);
                  
DelayCommand(8.5CheckFugue(oPC));
               }
       }
     }
     else if(
GetLocalInt(oMod,"DEATHSYSTEM") )
     {
        
SetLocalInt(oPC,"LOGINDEATH",1);
        
effect eDeath EffectDeath(FALSEFALSE);
        if(
nCurState == PWS_PLAYER_STATE_DEAD)
            
ApplyEffectToObject(DURATION_TYPE_INSTANTeDeathoPC);
     }
     
// hcr3 7/25/2003 remarked out due to quirky behavior on enter.
     /*if(!GetLocalInt(oMod,"PRIORTHISREBOOT"+sCDK+GetName(oPC)))
     {
        if(nCurState!=PWS_PLAYER_STATE_DEAD)
            DelayCommand(5.0,PWDB_PlaceCharacter(oPC));
        SetLocalInt(oMod,"PRIORTHISREBOOT"+sCDK+GetName(oPC),1);
     }*/
    
}// end if deathsystem

    
InitPCHTFLevels(oPC);

    if(!(
GetXP(oPC)))
        
SetXP(oPC1);
    
// Send a login message to all players if one exists
    
if(GetLocalString(oMod,"LOGINMESSAGE") != "NONE")
        
SendMessageToPC(oPC,GetLocalString(oMod,"LOGINMESSAGE"));
    
// check to see if the pc has entered before. if so run strip talents.
    // hcr3 7/25/2003
    // changed to local no longer need persistent var.
    
if(GetLocalInt(oMod,"DECONENTER"))
      if (
GetLocalInt(oPC"ENTERED"))
         
ExecuteScript"hc_strip_talents"GetEnteringObject());
    
// hcr3.1 added delay.
    
DelayCommand(10.0SetLocalInt(oPC"ENTERED"TRUE));
    
postEvent();

__________________
..::Heavenlynet le net paradisiaque ::..
http://gw.heaven-ly.net/images/stories/divers/sigfg042.gif
Citation :
Provient du message de Azrael07
Chaque passage incrémente la variable temporelle
Euh...
Je comprend bien le principe de liste chaînée mais le parcours de cette liste doit bien se faire plusieurs fois toutes les xxx secondes non ?
__________________
..::Heavenlynet le net paradisiaque ::..
http://gw.heaven-ly.net/images/stories/divers/sigfg042.gif
Citation :
Euh...
Je comprend bien le principe de liste chaînée mais le parcours de cette liste doit bien se faire plusieurs fois toutes les xxx secondes non ?
bah justement l'idée c'est de ne passer en revue tout les 10^-2 secondes (ou qlqc comme ca) que le premier élément de la liste. Comme la liste est classé par ordre temporel, du déclenchement le plus imminant jusqu'au plus lointain, il suffit de passer en revue les premiers éléments jusqu'a ce qu'il y en ait un qui ne passe plus, et les suivants ne passeront donc forcement plus non plus.

C'est une technique asset connus, et a mon avis la plus appropriée pour ce genre de chose, ce qui fait du DelayCommand une fonction asset interessante.

Bon, après je n'ai pas vu le code source, j'ai pas la preuve absolue qu'ils ont procédé comme ca, mais ca m'étonnerait fort que tout les évenements soient passés en revue tout les 10^-2 secondes.
Répondre

Connectés sur ce fil

 
1 connecté (0 membre et 1 invité) Afficher la liste détaillée des connectés