Aller au contenu

Photo

Broken script help?


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

#1
Who said that I

Who said that I
  • Members
  • 492 messages
Okay, got this script to lock prestige classes.....now it worked just fine for the past year orso...but suddenly it stops working.....I do not know if its a wrong part on my side since I am still ot the greatest in scripting.

The script is meant to lock PRC classes, but it sorta doesnt once the toon has the requirements for it....and thats not really what we are looking for, since we have a token system running for the prestige classes and stuff.

But if anyone can tell me if a script can  "break "after a while or is there something else that can cause this?


Below I will post the script:


#include "_pw_journal_inc"
void main()
{
object oPC = GetEnteringObject();
RestorePersistentJournal(oPC);
ExecuteScript ("cnr_module_oce", oPC);
}
void DisableAllPrestigeclasses(object oPC, int bExistingToo=FALSE)
{
 if(bExistingToo || GetLevelByclass(class_TYPE_SHADOWDANCER,oPC) < 1)
 {
 SetLocalInt(oPC,"X1_AllowShadow",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_HARPER,oPC) < 1)
 {
 SetLocalInt(oPC,"X1_AllowHarper",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_ARCANE_ARCHER,oPC) < 1)
 {
 SetLocalInt(oPC,"X1_AllowArcher",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_ASSASSIN,oPC) < 1)
 {
 SetLocalInt(oPC,"X1_AllowAsasin",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_BLACKGUARD,oPC) < 1)
 {
 SetLocalInt(oPC,"X1_AllowBlkGrd",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_DIVINE_CHAMPION,oPC) < 1)
 {
 SetLocalInt(oPC,"X2_AllowDivcha",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_WEAPON_MASTER,oPC) < 1)
 {
 SetLocalInt(oPC,"X2_AllowWM",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_PALE_MASTER,oPC) < 1)
 {
 SetLocalInt(oPC,"X2_AllowPalema",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_SHIFTER,oPC) < 1)
 {
 SetLocalInt(oPC,"X2_AllowShiftr",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_DWARVEN_DEFENDER,oPC) < 1)
 {
 SetLocalInt(oPC,"X1_AllowDwDef",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_DRAGON_DISCIPLE,oPC) < 1)
 {
 SetLocalInt(oPC,"X1_AllowDrDis",1);
 }
 if(bExistingToo || GetLevelByclass(class_TYPE_PURPLE_DRAGON_KNIGHT,oPC) < 1)
 {
 SetLocalInt(oPC,"DLA_AllowPDK",1);
 }
}

been working on this with some others on it to fix the issue but we sorta created a hole in our walls now....so if someone can tell me whats the issue than?

#2
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Scripts only will "break" if you did something to break it. They don't do it on there own. Somewhere, somehow, somebody has made an alteration that is now affecting the script results. You may have to narrow down what changes have been made since the script began not working correctly.

#3
dickloraine

dickloraine
  • Members
  • 4 messages
On the first look, your DisableAllPrestigeclasses function is nowhere in the void main. So it is never executed. Or is this also an include? But then there shouldn't be a main function.

#4
NorthWolf

NorthWolf
  • Members
  • 86 messages
As _Knightmare_ said, scripts don't degrade or anything. From what I can see the problem might be really simple, as I'm guessing that's your "onEnter" script: you never actually call "DisableAllPrestigeclasses()". This should work, I'm guessing:

void DisableAllPrestigeclasses(object oPC, int bExistingToo=FALSE){
 if(bExistingToo || GetLevelByclass(class_TYPE_SHADOWDANCER,oPC) < 1)
 SetLocalInt(oPC,"X1_AllowShadow",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_HARPER,oPC) < 1)
 SetLocalInt(oPC,"X1_AllowHarper",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_ARCANE_ARCHER,oPC) < 1)
 SetLocalInt(oPC,"X1_AllowArcher",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_ASSASSIN,oPC) < 1)
 SetLocalInt(oPC,"X1_AllowAsasin",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_BLACKGUARD,oPC) < 1)
 SetLocalInt(oPC,"X1_AllowBlkGrd",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_DIVINE_CHAMPION,oPC) < 1)
 SetLocalInt(oPC,"X2_AllowDivcha",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_WEAPON_MASTER,oPC) < 1)
 SetLocalInt(oPC,"X2_AllowWM",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_PALE_MASTER,oPC) < 1)
 SetLocalInt(oPC,"X2_AllowPalema",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_SHIFTER,oPC) < 1)
 SetLocalInt(oPC,"X2_AllowShiftr",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_DWARVEN_DEFENDER,oPC) < 1)
 SetLocalInt(oPC,"X1_AllowDwDef",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_DRAGON_DISCIPLE,oPC) < 1)
 SetLocalInt(oPC,"X1_AllowDrDis",1);
 if(bExistingToo || GetLevelByclass(class_TYPE_PURPLE_DRAGON_KNIGHT,oPC) < 1)
 SetLocalInt(oPC,"DLA_AllowPDK",1);
}

void main()
{
object oPC = GetEnteringObject();
RestorePersistentJournal(oPC);
DisableAllPrestigeclasses(oPC);
ExecuteScript ("cnr_module_oce", oPC);
}

Modifié par NorthWolf, 04 décembre 2010 - 05:54 .


#5
Who said that I

Who said that I
  • Members
  • 492 messages
thank you all, am gonna try this out and let you guys know the results!

#6
Who said that I

Who said that I
  • Members
  • 492 messages
Error, no right bracket on expression -> if(bExistingToo || GetLevelByclass(class_TYPE_SHADOWDANCER,oPC) < 1)



Which makes no sense to me since it worked for me earlier without any trouble!

#7
420

420
  • Members
  • 190 messages

Who said that I wrote...

Error, no right bracket on expression -> if(bExistingToo || GetLevelByclass(class_TYPE_SHADOWDANCER,oPC)

Which makes no sense to me since it worked for me earlier without any trouble!

That happens sometimes, try cutting the lines, compiling then readding the linse.

-420

#8
NorthWolf

NorthWolf
  • Members
  • 86 messages
For some reason my post keeps correcting the code to be... incorrect. I have no clue why. The problem is with capitalization of the "GetLevelByclass" function. The word "class" should be capitalized at the start, but the forums seem to hate the capital C.

Just go through and fix the capitals if you copied and pasted.

Modifié par NorthWolf, 04 décembre 2010 - 08:43 .


#9
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
All the consts should have the word 'class' in all caps too (like this, without the spaces: C L A S S. Forum probably thinks you're trying to define a class and is blocking it. Or...something. :P

Funky

Modifié par FunkySwerve, 04 décembre 2010 - 08:57 .


#10
NorthWolf

NorthWolf
  • Members
  • 86 messages
Oh, wow. Just noticed that. That's a really weird bug/protection/whatever it is.

#11
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Aslo dont forget to leave the

#include "_pw_journal_inc"

At the top of the script.

#12
Who said that I

Who said that I
  • Members
  • 492 messages
it still does the same really....still the same error or I made a reading error....



//::::::::::::::::::::: OnClientEnter script :::::::::::::::::::::::::::::::::::



#include "_pw_journal_inc"



void DisableAllPrestigeclasses(object oPC, int bExistingToo=FALSE){

if(bExistingToo || GetLevelByclass(class_TYPE_SHADOWDANCER,oPC) < 1)

SetLocalInt(oPC,"X1_AllowShadow",1);

if(bExistingToo || GetLevelByclass(class_TYPE_HARPER,oPC) < 1)

SetLocalInt(oPC,"X1_AllowHarper",1);

if(bExistingToo || GetLevelByclass(class_TYPE_ARCANE_ARCHER,oPC) < 1)

SetLocalInt(oPC,"X1_AllowArcher",1);

if(bExistingToo || GetLevelByclass(class_TYPE_ASSASSIN,oPC) < 1)

SetLocalInt(oPC,"X1_AllowAsasin",1);

if(bExistingToo || GetLevelByclass(class_TYPE_BLACKGUARD,oPC) < 1)

SetLocalInt(oPC,"X1_AllowBlkGrd",1);

if(bExistingToo || GetLevelByclass(class_TYPE_DIVINE_CHAMPION,oPC) < 1)

SetLocalInt(oPC,"X2_AllowDivcha",1);

if(bExistingToo || GetLevelByclass(class_TYPE_WEAPON_MASTER,oPC) < 1)

SetLocalInt(oPC,"X2_AllowWM",1);

if(bExistingToo || GetLevelByclass(class_TYPE_PALE_MASTER,oPC) < 1)

SetLocalInt(oPC,"X2_AllowPalema",1);

if(bExistingToo || GetLevelByclass(class_TYPE_SHIFTER,oPC) < 1)

SetLocalInt(oPC,"X2_AllowShiftr",1);

if(bExistingToo || GetLevelByclass(class_TYPE_DWARVEN_DEFENDER,oPC) < 1)

SetLocalInt(oPC,"X1_AllowDwDef",1);

if(bExistingToo || GetLevelByclass(class_TYPE_DRAGON_DISCIPLE,oPC) < 1)

SetLocalInt(oPC,"X1_AllowDrDis",1);

if(bExistingToo || GetLevelByclass(class_TYPE_PURPLE_DRAGON_KNIGHT,oPC) < 1)

SetLocalInt(oPC,"DLA_AllowPDK",1);

}



void main()

{

object oPC = GetEnteringObject();

RestorePersistentJournal(oPC);

DisableAllPrestigeclasses(oPC);

ExecuteScript ("cnr_module_oce", oPC);

}


#13
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
 Are the caps correct in your script.  
 
//::::::::::::::::::::: OnClientEnter script :::::::::::::::::::::::::::::::::::
     class   

#include "_pw_journal_inc"

void DisableAllPrestigeClasses(object oPC, int bExistingToo=FALSE){
if(bExistingToo || GetLevelByClass(class_TYPE_SHADOWDANCER,oPC)
SetLocalInt(oPC,"X1_AllowShadow",1);
if(bExistingToo || GetLevelByClass(class_TYPE_HARPER,oPC)
SetLocalInt(oPC,"X1_AllowHarper",1);
if(bExistingToo || GetLevelByClass(class_TYPE_ARCANE_ARCHER,oPC)
SetLocalInt(oPC,"X1_AllowArcher",1);
if(bExistingToo || GetLevelByClass(class_TYPE_ASSASSIN,oPC)
SetLocalInt(oPC,"X1_AllowAsasin",1);
if(bExistingToo || GetLevelByC lass(class_TYPE_BLACKGUARD,oPC)
SetLocalInt(oPC,"X1_AllowBlkGrd",1);
if(bExistingToo || GetLevelByC lass(class_TYPE_DIVINE_CHAMPION,oPC)
SetLocalInt(oPC,"X2_AllowDivcha",1);
if(bExistingToo || GetLevelByC lass(class_TYPE_WEAPON_MASTER,oPC)
SetLocalInt(oPC,"X2_AllowWM",1);
if(bExistingToo || GetLevelByC lass(class_TYPE_PALE_MASTER,oPC)
SetLocalInt(oPC,"X2_AllowPalema",1);
if(bExistingToo || GetLevelByC lass(class_TYPE_SHIFTER,oPC)
SetLocalInt(oPC,"X2_AllowShiftr",1);
if(bExistingToo || GetLevelByC lass(class_TYPE_DWARVEN_DEFENDER,oPC)
SetLocalInt(oPC,"X1_AllowDwDef",1);
if(bExistingToo || GetLevelByC lass(class_TYPE_DRAGON_DISCIPLE,oPC)
SetLocalInt(oPC,"X1_AllowDrDis",1);
if(bExistingToo || GetLevelByClass(class_TYPE_PURPLE_DRAGON_KNIGHT,oPC)
SetLocalInt(oPC,"DLA_AllowPDK",1);
}

void main()
{
object oPC = GetEnteringObject();
RestorePersistentJournal(oPC);
DisableAllPrestigeClasses(oPC);
ExecuteScript ("cnr_module_oce", oPC);
}
 

#14
Baragg

Baragg
  • Members
  • 271 messages
You may need to set the TRUE on the Disable call.



You have DisableAllPrestigeclasses(oPC);



Where I think it should be DisableAllPrestigeclasses(oPC, TRUE);

#15
Who said that I

Who said that I
  • Members
  • 492 messages
Yes I noticed it when I put in that last post! Thanks so much for your help guys!!

#16
Who said that I

Who said that I
  • Members
  • 492 messages
okay this is REALLY getting on my nerves here....compiling goes wohoo! But when I try it out my toon can still take the freaking class.....which is not what the script is supposed to do....



anyone else has an idea here?

#17
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Does this system also have a script for the OnPlayerLevelUp event? It most likely should. Then when the player levels, It checks for the int and whether or not it is true or false allowing the player to take the class.

Modifié par GhostOfGod, 07 décembre 2010 - 03:11 .


#18
Who said that I

Who said that I
  • Members
  • 492 messages
well, no, well I cannot recall it had that script. Since we (used) tokens in order to unlock the prclasses.

#19
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
All the script you've been editing does is to set a local variable with Allow in the name on the character when they log in, if they already have the class in question. This is presumably to grandfather in those that already have it, if they don't have other permission. You still need something in onlevelup to block them taking the levels unless the variable in question is set. Basically, you check to see if they have the token item or the specific Allow variable, and if not, and they have the disallowed class, delevel them with a message explaining why. I'll post an example script in a couple minutes.



Funky

#20
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
That is the old system Funky.  The vars set on the Character are tied to hard code in the engine that should prevent the character from leveling.  I think the problem my be that thier server may be using modifyed 2da's that are either missing the value for the var name or they have edited the 2da to change the name of the var.  Perhaps in the way shadow has suggested in the past.

Checking the 2da's on for the server to make sure the var names are right would be the next step i would take. 

Here is the link to the last time i remember this topic being fought out. 

 http://nwn.bioware.c...724682&forum=47

#21
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
Bah, having connectivity issues. Here's the onlevelup code to block taking of prestige classes. It uses a different variable than your client enter script, so I'm providing a modified client enter script as well. It assumes the tokens that allow a prestige will have tags of the format:
Allowclass_X
Where x is the number of the class, taken from the const. The numbers are:
Shadowdancer 27
Harper 28
Arcane_Archer 29
Assassin 30
Blackguard 31
Champion of Torm 32
Weaponmaster 33
Pale Master 34
Shifter 35
Dwarven Defender 36
Dragon Disciple 37
Purple Dragon Knight 41
So a token allowing the player to take shadowdancer levels would have to have the tag Allowclass_27, for example.

Here's the onlevelup:
void DelevelPC(object oPC) {
    int nLevel = GetHitDice(oPC);
    int nNewXP = ((nLevel * (nLevel - 1)) / 2 * 1000) - 1;

    SetXP(oPC, nNewXP);
}
void CheckRestrictedclass(object oPC, int nclass) {
    if (GetLevelByclass(nclass, oPC) > 0) {
        if (!GetLocalInt(oPC, "Allowclass_"+IntToString(nclass)) &&
            !GetIsObjectValid(GetItemPossessedBy(oPC, "Allowclass_"+IntToString(nclass)))) {
            DelevelPC(oPC);
            FloatingTextStringOnCreature("You cannot take prestige classes without the required token!", oPC, FALSE);
        }
    }
}

void main() {
    object oPC = GetPCLevellingUp();
    int nX;
    for (nX = 27; nX < 42; nX++)
        CheckRestrictedclass(oPC, nX);

}




And here is the onenter code, modified to use the new variable:



#include "_pw_journal_inc"

void GrandfatherPrestigeclasses(object oPC) {
    int nX;
    for (nX = 27; nX < 42; nX++) {
        if (GetLevelByclass(nX, oPC) > 0)
            SetLocalInt(oPC, "Allowclass_"+IntToString(nX), 1);
    }
}

void main()
{
    object oPC = GetEnteringObject();
    RestorePersistentJournal(oPC);
    GrandfatherPrestigeclasses(oPC);
    ExecuteScript ("cnr_module_oce", oPC);
}

In case you're wondering WHY I switched to using a new variable, it was so I could do those tidy little for loops instead of a big clunky list.

Funky

Modifié par FunkySwerve, 07 décembre 2010 - 08:41 .


#22
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
Sigh, finally got through again. Just a reminder to capitalize all instances of 'class' and 'classes'.



Funky

#23
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages

Lightfoot8 wrote...

That is the old system Funky.

Ah, only just saw this - internet is driving me crazy today. That's interesting, I wasn't aware of such a setup, though it's handy. Likely because we've never blocked a prestige on HG. :P  Anyway, the code I gave him will work, though I'm glad of my instinct to change the vars.

Funky

#24
Who said that I

Who said that I
  • Members
  • 492 messages
okay so if I put this in what you have send me Funky I will be able to lock those prestige classes again?

#25
Who said that I

Who said that I
  • Members
  • 492 messages
hmm I wonder if the Subrace engine of Shayan could have changed the 2da files maybe? That is the only add-on "I" have added to the module