Aller au contenu

Photo

Every Six Minutes XP


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

#1
WhenTheNightComes

WhenTheNightComes
  • Members
  • 27 messages
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.

#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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();
}

#3
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
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

#4
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Nice Funky. I still never know when to use or not use the mod HB. :blush:

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