Author Topic: Auto Saving Characters!  (Read 310 times)

Legacy_WindAngel

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Auto Saving Characters!
« on: April 15, 2011, 04:02:22 am »


               Hey all, one more question then my server will be up!

How do i go about making it so the characters in my server are automatically saved every 2 mins. Without showing the text "Character Saved" Or, if not possible then it is fine to show the text.

As before, i am not good at scripting such ... so please be thorough and step by step. I appreciate ANY replies.

Thank you!
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Auto Saving Characters!
« Reply #1 on: April 15, 2011, 08:50:13 am »


               There are several ways to go about this and some of it depends on what you are doing in your mod.

Here's one version you could do so long as your are not allowing players to have anything other than the default player appearances. It keeps polymorphed characters from being saved to prevent a bug. You would implement it into your OnModuleLoad script:


//Put this on the top of our OnModuleLoad script or make it a separate include.
const float DELAY = 120.0f; //2 minutes
void ExportAllPlayers()
{
    object oPC = GetFirstPC();
    while ( GetIsObjectValid(oPC))
    {
        if(GetAppearanceType(oPC) > 6)
        {
           SendMessageToPC(oPC, "Your character can not be saved while polymorphed");
        }
        else
        {
           ExportSingleCharacter(oPC);
           SendMessageToPC(oPC, "Your character has been saved");
        }
        oPC = GetNextPC();
    }
    DelayCommand(DELAY, ExportAllPlayers());
}

//OnModuleLoad example...
void main()
{
    //stuff
    //more stuff
    //lots of other stuff

    DelayCommand(120.0, ExportAllPlayers());//Add this line to your OnModuleLoad script
}


Hope it helps. Good luck.
               
               

               


                     Modifié par GhostOfGod, 15 avril 2011 - 07:51 .