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.
Every Six Minutes XP
Débuté par
WhenTheNightComes
, mai 01 2013 08:37
#1
Posté 01 mai 2013 - 08:37
#2
Posté 02 mai 2013 - 12:53
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();
}
//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
Posté 02 mai 2013 - 01:29
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:
Funky
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
Posté 02 mai 2013 - 02:28
Nice Funky. I still never know when to use or not use the mod HB.
Modifié par GhostOfGod, 02 mai 2013 - 02:28 .





Retour en haut






