Author Topic: Every Six Minutes XP  (Read 304 times)

Legacy_WhenTheNightComes

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +0/-0
Every Six Minutes XP
« on: May 01, 2013, 09:37:19 pm »


               I'd like to check every six minutes for a campaign integer for each PC online. Then giving out the integer number XP to the player, and repeat every six minutes. I'm not sure where I'd put this, or really how to script it.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Every Six Minutes XP
« Reply #1 on: May 02, 2013, 01:53:43 am »


               Could try something like this in the "OnModuleLoad" event (or just add it to your existing one):

//How much XP to give per interval:
const int XP_AMOUNT = 25;

//How many minutes per interval:
const int X_MINUTES = 6;

void GiveTimedXPToAllPlayers()
{
    object oPC = GetFirstPC();
    int iCheck;
    while (GetIsObjectValid(oPC))
    {
        //checks standard int on player:
        iCheck = GetLocalInt(oPC, "var name");
        //checks for campaign int for specific player:
        //iCheck = GetCampaignInt("campaign name", "var name", oPC);
        if (iCheck == ??)//<--check for what number here
        {
            GiveXPToCreature(oPC, XP_AMOUNT);
        }
        oPC = GetNextPC();
    }
    DelayCommand(IntToFloat(X_MINUTES * 60), GiveTimedXPToAllPlayers());
}

//OnModuleLoad
void main()
{
    GiveTimedXPToAllPlayers();
}
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Every Six Minutes XP
« Reply #2 on: May 02, 2013, 02:29:56 am »


               That's a pseudo. It'll cost roughly 5 times the cpu than just putting it in mod heartbeat, where code like this really belongs. I would also avoid calling up campaign ints so many times, by loading the campaign ints into local ints oncliententer.

To do this from mod hearbeat, just use modulo, on an incrementing counter. It'd look something like this:

void main() {
    object oMod = GetModule();
    int nUptime = GetLocalInt(oMod, "uptime");
    if (!(nUptime%360)) {
    //do stuff here (loop pcs and give xp based on their variables)

    }
    nUptime += 6;//mod heartbeat runs about every 6 seconds
    SetLocalInt(oMod, "uptime", nUptime);

}

Funky
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Every Six Minutes XP
« Reply #3 on: May 02, 2013, 03:28:38 am »


               Nice Funky. I still never know when to use or not use the mod HB. ':blush:'
               
               

               


                     Modifié par GhostOfGod, 02 mai 2013 - 02:28 .