Aller au contenu

Photo

Level-up script


  • Veuillez vous connecter pour répondre
1 réponse à ce sujet

#1
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

I need a level up script that will fire an  ExecuteScript("n_spiritguide", oPC);  command when class 67 reaches level 2 and only when class 67 reaches level 2.

 

I have this thus far but it is firing for every class at every level:

#include "x0_i0_henchman"
 
int SummonGuide(object oPC)
{
    // detect if the character is class 67, level 2
    int nLEVEL = GetLevelByClass(67, oPC);
if (nLEVEL = 2)
    {
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}
 
void main()
{
    object oPC =  GetPCLevellingUp();
    if(SummonGuide(oPC)<1)
 {
     ExecuteScript("n_spiritguide", oPC);
          }
 {
     LevelUpXP1Henchman(oPC);
 }
}


#2
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

The if check in SummonGuide subroutine did not have double equal, and the if check in the void main() probably did the opposite of what you wanted, as I believe that TRUE is equal to 1. You may also wanna delay the leveluphenchman command to make sure that it fires after everything else in the script has been done.

There will be another issue, this script will fire again at every levelup if you stay at level 2 with class 67 and level up with another class, to prevent that I added a check with a local variable, it should do for the time being. Try with this and see if it fixes your problem.

#include "x0_i0_henchman"
 
int SummonGuide(object oPC)
{
    // detect if the character is class 67, level 2
    int nLEVEL = GetLevelByClass(67, oPC);
    int nCHECK = GetLocalInt(oPC, "spiritguide_check");
    if ((nLEVEL == 2)&&(nCHECK != TRUE)) return TRUE;
    else return FALSE;
}

void main()
{
    object oPC =  GetPCLevellingUp();
    if(SummonGuide(oPC)==TRUE)
    {
        SetLocalInt(oPC, "spiritguide_check", TRUE);
        ExecuteScript("n_spiritguide", oPC);
    }
    DelayCommand(0.0f, LevelUpXP1Henchman(oPC));
}