Author Topic: Help with blockning PrCs / unbloking with item.  (Read 503 times)

Legacy_Arawan

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Help with blockning PrCs / unbloking with item.
« on: September 21, 2010, 04:18:46 pm »


               Hi all,

I am trying to block  / ban PrCs and only allow them by tokens that can be handed out by DMs or by quest NPCs. 

I have found these two pieces of code on the old forum:

For the OnClientEnter: 

SetLocalInt(oPC,"X1_AllowDrDis",1);
   SetLocalInt(oPC,"X2_AllowShiftr",1);
   SetLocalInt(oPC,"X2_AllowDivcha",1);
   SetLocalInt(oPC,"X2_AllowWM",1);
   SetLocalInt(oPC,"X1_AllowHarper",1);
   SetLocalInt(oPC,"X1_AllowAsasin",1);
   SetLocalInt(oPC,"X1_AllowArcher",1);
   SetLocalInt(oPC,"X1_AllowBlkGrd",1);
   SetLocalInt(oPC,"X1_AllowDwDef",1);
   SetLocalInt(oPC,"X2_AllowPalema",1);
   SetLocalInt(oPC,"X1_AllowShadow",1);


For the OnAquireItem: 

object oItem = GetModuleItemAcquired();
   object oPC = GetModuleItemAcquiredBy();
   string tagged = GetTag(oItem);
   if (tagged == "AssassinToken") {
       SetLocalInt(oPC, "X1_AllowAsasin", 0);
   }
   else if (tagged == "ShadowdancerToken") {
       SetLocalInt(oPC, "X1_AllowShadowdancer", 0);
   }
   else if (tagged == "HarperToken") {
       SetLocalInt(oPC, "X1_AllowHarper", 0);
   }
   else if (tagged == "ArcaneArcherToken") {
       SetLocalInt(oPC, "X1_AllowArcher", 0);
   }
   else if (tagged == "BlackguardToken") {
       SetLocalInt(oPC, "X1_AllowBrg", 0);
   }
   else if (tagged == "DivinechampionToken") {
       SetLocalInt(oPC, "X1_AllowDivcha", 0);
   }
   else if (tagged == "WeaponmasterToken") {
       SetLocalInt(oPC, "X1_AllowWM", 0);
   }
   else if (tagged == "PalemasterToken") {
       SetLocalInt(oPC, "X1_AllowPalema", 0);
   }
   else if (tagged == "ShifterToken") {
       SetLocalInt(oPC, "X1_AllowShiftr", 0);
   }
   else if (tagged == "DwarvenDefenderToken") {
       SetLocalInt(oPC, "X1_AllowDwDef", 0);
   }
   else if (tagged == "DragonDiscipleToken") {
       SetLocalInt(oPC, "X1_AllowDrDis", 0);
   }
   else if (tagged == "PurpleDragonKnightToken") {
       SetLocalInt(oPC, "DLA_AllowPDK", 0);
   }
   else {}


I tried adding them to my existing scripts:

OnClientEnter: 

/*////////////////////////////////////////////////////////
----------------------------------------------------------
Script Name: gen_client_enter
----------------------------------------------------------
Created By: Genisys(Guile)
Created On: 4/23/08
Updated On: 9/09/09
----------------------------------------------------------
This is my premier OnClientEnter Module Event script
It is set up for single & multiplayer mode!
----------------------------------------------------------
///////////////////////////////////////////////////////////

NOTE: You can remove bann from ALL players, by
destroying the database BANNED from your "database" folder,
also, note that the database is used across any module
you create using this module!

///////////////////////////////////////////////////////////

This script does multiple things, it checks to see if...
If the PC is immortal or level 40 (apply special effects)
If the character they have has been banned. (not a total bann)
If they logged out while dead, if so make them dead instantly!!! '<img'>
If the player is playing a legal character or not...read below..
And if the Player themself have been banned from the module or not..

////////color useage defined///////////

Colors Defined

1 = Red (Bright)    2 = Aqua Marine
3 = Magenta         4 = Purple
5 = Pink            6 = Olive
7 = Peach           8 = Light Grey
9 = Gold            10 = Cyan
11 = Orange          12 = Sky Blue
13 = Lavender        14 = Tan
15 = Light Green     16 = Icy Blue
17 = Deep Blue Sea   18 = Dark Cyan    19 = Pure White (Full Intensity)


Example of use in script..

string sMsg = SetColorMessage(19, "Blah blah..");

This would return:   Blah blah..   (*in pure white)


----------------------------------------------------------
/////////////////////////////////////////////////////////*/

//Redundant Variables Declared
effect eEffect;
int nInt;
object oItem;
object aTarget;
location bTarget;

//Required includes for this script (don't touch!)
#include "x3_inc_horse"
#include "_inc_gen_color_"
#include "nw_i0_plot"

//PROTOTYPE DECLARED (don't touch!)
void SendMessageToAllPC(string sMessage);
void GiveDMItems(object oDM);
void GivePCItems(object oDM);

///////////////////////////////////////////////////////////////////////////

//Main Script
void main()
{

//Declare ALL Major Variables..
object oPC;
oPC = GetEnteringObject();
object oTarget;
oTarget = oPC;
object oPlayer = oPC;
object oPP = oPC;
string sCDKey = GetPCPublicCDKey(oPC, FALSE);
object oToken = GetItemPossessedBy(oPC, "idtoken");
string sName = GetName(oToken);
int nHP = GetLocalInt(oToken, "CURRENT_HP");
int nNHP, nCHP, nHHP, nDHP;
effect eEffect;
int nXP = GetLocalInt(oToken, "CURRENT_XP");
int nCXP = GetXP(oPC);
string sXP;
int y = nCXP - nXP;
int MULTI = GetLocalInt(GetModule(), "multi");
object oP = GetItemPossessedBy(oPC, "_pc_pouch");


////////////////////////////////////////////////////////////////
/*   STILL TESTING THIS...

if(nCXP!=nXP)
{
if(y>=4801) //More than 6 kills at level 40 in 15 seconds TOUGH!
{           //Warn DMs that something fishy is going on!

 sXP = GetName(oPC);
 sXP += " had - ";
 sXP += IntToString(nXP);
 sXP += " XP, but logged in with - ";
 sXP += IntToString(nCXP);
 sXP += " XP - Investigate.";
 SendMessageToAllDMs(sXP);
}
}
*/

//If it's a DM entering...
if(GetIsDM(oPC))
{
AddJournalQuestEntry("dmrules", 1, oPC, FALSE, FALSE);
GiveDMItems(oPC); //Give the DM items..
return;// Stop here!
}

////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////
//Remove plot or immortal from PC if they have it..
SetPlotFlag(oPC, FALSE);
SetImmortal(oPC, FALSE); //Accidents happen '<img'>

////////////////////////////////////////////////////////////////
//Handle PC Items here..


////////////////////////////////////////////////////////////////
//Higher Ground's Legendary leveler

//If in fact it's a multiplayer game...
int MULTI_PLAYER = GetLocalInt(GetModule(), "multi");
if(MULTI_PLAYER)
{
string Script = GetLocalString(oPC, "LetoScript");

   if( Script != "" )
   {
       SetLocalString(oPC, "LetoScript", "");
   }
}
///////////////////////////////////////////////////////////////////////
//Entering Message to All PCs..

//Please leave the credits to the module within the message.

/*

1 = Red (Bright)    2 = Aqua Marine
3 = Magenta         4 = Purple
5 = Pink            6 = Olive
7 = Peach           8 = Light Grey
9 = Gold            10 = Cyan
11 = Orange          12 = Sky Blue
13 = Lavender        14 = Tan
15 = Light Green     16 = Icy Blue
17 = Deep Blue Sea   18 = Dark Cyan      19 = PURE White (FUll Intensity!)

Example sMessage =  SetColorMessage(3, "whatever");
*/

//Colorful Server Message sent to all PCs when they enter the module..
string sMessage;
sMessage =  SetColorMessage(7, "Welcome to a ");
sMessage += SetColorMessage(10, "~ 1.69 / CEP 2.2 Persistant Starter Module ~ \\n");
sMessage += SetColorMessage(7, "For Single Player ");
sMessage += SetColorMessage(7, "or Multi-Player / Online Server Modules \\n");
sMessage += SetColorMessage(12, "Created By ");
sMessage += SetColorMessage(10, "Genisys (Guile) ");
sMessage += SetColorMessage(12, "From 4/22/08 - 7/31/10 !");


//Tell the new visitor..
string sNewb;
string sNewb2;

sNewb = SetColorMessage(12, "If you'd like to ask some questions, contact me at: ");
sNewb += SetColorMessage(10, "galefer003@hotmail.com");

sNewb2 = SetColorMessage(18, "Thanks for using the module & as always, ENJOY!");

string sEnter = GetName(oPC) + " / " + GetPCPlayerName(oPC) + " / " + GetPCPublicCDKey(oPC) + " / " + GetPCIPAddress(oPC) + " Entered." ;
SendMessageToAllDMs(sEnter);
WriteTimestampedLogEntry(sEnter);

string sEnter2 = GetRGB(15,1,1) + GetName(oPC) + " / " + GetPCPlayerName(oPC) + " / " + GetPCPublicCDKey(oPC) + " / " + GetPCIPAddress(oPC) + " Has Entered. </c>" ;
SendMessageToAllPC(sEnter2);

//Float welcome message by..
DelayCommand(12.3, FloatingTextStringOnCreature(sMessage, oPC, FALSE));

if(GetHitDice(oPC)<=6)
{
DelayCommand(14.3, FloatingTextStringOnCreature(sNewb, oPC, FALSE));
DelayCommand(24.3, FloatingTextStringOnCreature(sNewb2, oPC, FALSE));
}

if(oToken !=OBJECT_INVALID && MULTI_PLAYER) //It's a multiplayermodule..
{
if(GetLocalInt(GetModule(), sName))
{
 DelayCommand(7.0,
 FloatingTextStringOnCreature("Welcome back!", oPC, FALSE));
}
//Otherwise set that they have visited the module recently since restart!
else
{
 SetLocalInt(GetModule(), sName, TRUE);
 sNewb = SetColorMessage(9, "Greetings Everyone!");
 if(MULTI_PLAYER)
 {
  AssignCommand(oPC, ActionSpeakString(sNewb, TALKVOLUME_SHOUT));
 }
}
}
else
{
sNewb = SetColorMessage(9, "Greetings Everyone!");
 if(MULTI_PLAYER)
 {
  AssignCommand(oPC, ActionSpeakString(sNewb, TALKVOLUME_SHOUT));
 }
}
//////////////////////////////////////////////////////////////////

object oTag;
location lTag;


//This part is about verifying the Player's name..
//A player must have at least a 2 character name or they are going to
//return with an error!  If they have spaces in their name it will return
//with an error as well, including alt code!
string sPCNM = GetName(oPP);
string sPCNMR = GetStringRight(sPCNM, 2);
string sNC1; string sNC2; string sRNC1; string sRNC2;
int nBad;

//Find the second character of the players name..
sNC1 = GetSubString(sPCNM, 0, 1);
//Find the second character of the players name..
sNC2 = GetSubString(sPCNM, 0, 2);
//Find the last letter in the player's name.
sRNC1 = GetSubString(sPCNMR, 0, 1);
//Find the next to the last letter in the player's name.
sRNC2 = GetSubString(sPCNMR, 0, 2);

/////////////////////////IMPORTANT//////////////////////////////////
//You must make all the "" below into " " to check for legal names
//I turned it off because a lot of my characters have bad names!
//Simply put the cursor between "" and hit the space bar for "" to " "
if(sNC1 ==" ")
{ nBad =1; }
else if(sNC2 ==" ")
{ nBad =1; }
else if(sRNC1 ==" ")
{ nBad =1; }
else if(sRNC2 ==" ")
{ nBad =1; }
else { nBad = 0; }

//See below to activate this system..
////////////////////////////////////////////////////////////////////////////

//Stop here if it's a DM entering...
if(GetIsDM(oPC))return;

////////////////////////////////////////////////////////////////////////////

//The Token System...
if(oToken == OBJECT_INVALID)
{
//This MUST be delayed!
DelayCommand(8.0, ExecuteScript("give_token", oPC));
}

//Give them their starting bag...
if(oP == OBJECT_INVALID)
{
 CreateItemOnObject("_pc_pouch", oPC, 1);
 GivePCItems(oPC);
 //Let's get their starting Information..
 DelayCommand(12.5, ExecuteScript("starting_stats", oPC));
}
else
{
 //Always ensure the PC Has ALL of their PC items...
 GivePCItems(oPC);
}


/////////////////////////////////////////////////////////////////////////////

//Check For Cheating, if it's a Multiplayer Game ONLY!
if(MULTI_PLAYER)
{
DelayCommand(8.0, ExecuteScript("cheat_check", oTarget));
}

//////////////////////////////////////////////////////////////////////
//These function add journal entries by the tag names below
//If you wish to create more, just copy / paste and change
//The tagname which is in "here", and the entry # remains 1 only!
if(MULTI_PLAYER)
{
//AddJournalQuestEntry("rules", 1, oPC, FALSE, FALSE);
//AddJournalQuestEntry("enchantinggems", 1, oPC, FALSE, FALSE);
//AddJournalQuestEntry("spells", 1, oPC, FALSE, FALSE);
//AddJournalQuestEntry("crafting", 1, oPC, FALSE, FALSE);
//AddJournalQuestEntry("server", 1, oPC, FALSE, FALSE);
}

//////////////////////////////////////////////////////////////////////////////
if(MULTI_PLAYER)
{
//For DM Players...
if(GetItemPossessedBy(oPC, "guildpass")!=OBJECT_INVALID)
      {
       //Lets make them concealed 50%
       eEffect = EffectConcealment(50);
       eEffect = SupernaturalEffect(eEffect);
       ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);

       eEffect = EffectHaste();
       eEffect = SupernaturalEffect(eEffect);
       ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
      }
}

//////////////////////////////////////////////////////////////////////////////
//If a player has been found with an illegal character they will have this item.
//It will prevent them from logging onto your server with that character.
//Note this will only work if you have activated the Anti-Cheat option above!
if(MULTI_PLAYER)
{
   if (GetItemPossessedBy(oPC, "banned")!= OBJECT_INVALID ||
   GetItemPossessedBy(oPC, "char_bann")!= OBJECT_INVALID ||
   GetCampaignInt("BANNED", "ADMIN_BANN", oPC)==2)
  {
  AssignCommand(oPC, ClearAllActions());

  SetCutsceneMode(oPC, TRUE);

  SetCameraMode(oPC, CAMERA_MODE_CHASE_CAMERA);

  DelayCommand(4.0, FloatingTextStringOnCreature("You have an illegal character which is not allowed on this server.", oPC));

  DelayCommand(5.0, SetCutsceneMode(oPC, FALSE));

  DelayCommand(6.0, BootPC(oPC));

  }
}
// */
////////////////////////////////////////////////////////////////////////////

if(MULTI_PLAYER)
{
//Since the player was dead when they logged, kill them!
if (GetLocalInt(oToken, "DEATH_STATE")==TRUE)
  {
   eEffect = EffectDeath();
   eEffect = SupernaturalEffect(eEffect);
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
   SendMessageToPC(oPC, "You died because you were dead when you logged out.");
  }

else
{
nCHP = GetCurrentHitPoints(oPC);
//If the player logged out while damaged...
if(nHP != nCHP  && nHP != 0)
{
  if(nHP>=1)
  {
     nNHP = nCHP - nHP;

     eEffect = EffectDamage(nNHP, DAMAGE_TYPE_POSITIVE, DAMAGE_POWER_ENERGY);
     DelayCommand(5.8, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC));
  }
  //Otherwise they must have had less than 1 hit points
  else
  {
    eEffect = EffectDeath();
    eEffect = SupernaturalEffect(eEffect);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
    SendMessageToPC(oPC, "You died because you were dead when you logged out.");
  }

 }
}
}

///////////////////////////////////////////////////////////////////
//Bioware Scripting For Handing Horses (DECATIVATED!!)

/*
   ExecuteScript("x3_mod_pre_enter",OBJECT_SELF); // Override for other skin systems

   if ((GetIsPC(oPC)||GetIsDM(oPC))&&!GetHasFeat(FEAT_HORSE_MENU,oPC))
   { // add horse menu
       HorseAddHorseMenu(oPC);
       if (GetLocalInt(GetModule(),"X3_ENABLE_MOUNT_DB"))
       { // restore PC horse status from database
           DelayCommand(2.0,HorseReloadFromDatabase(oPC,X3_HORSE_DATABASE));
       } // restore PC horse status from database
   } // add horse menu
   if (GetIsPC(oPC))
   { // more details
       // restore appearance in case you export your character in mounted form, etc.
       if (!GetSkinInt(oPC,"bX3_IS_MOUNTED")) HorseIfNotDefaultAppearanceChange(oPC);
       // pre-cache horse animations for player as attaching a tail to the model
       HorsePreloadAnimations(oPC);
       DelayCommand(3.0,HorseRestoreHenchmenLocations(oPC));
   } // more details

// DON'T TOUCH THIS LINE!! */

//Blocks the PrCs for entering players:

SetLocalInt(oPC,"X1_AllowDrDis",1);
   SetLocalInt(oPC,"X2_AllowShiftr",1);
   SetLocalInt(oPC,"X2_AllowDivcha",1);
   SetLocalInt(oPC,"X2_AllowWM",1);
   SetLocalInt(oPC,"X1_AllowHarper",1);
   SetLocalInt(oPC,"X1_AllowAsasin",1);
   SetLocalInt(oPC,"X1_AllowArcher",1);
   SetLocalInt(oPC,"X1_AllowBlkGrd",1);
   SetLocalInt(oPC,"X1_AllowDwDef",1);
   SetLocalInt(oPC,"X2_AllowPalema",1);
   SetLocalInt(oPC,"X1_AllowShadow",1);


//////////////////////////////////////////////////////
///////////////////////////////
}            //Main Script End
///////////////////////////////
/////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
//##################### ALL PROTOTYPES  DEFINED ########################//
//////////////////////////////////////////////////////////////////////////


//PROTOTYPE DEFINED
void SendMessageToAllPC(string sMessage)
{
  object oPC = GetFirstPC();
  while(GetIsObjectValid(oPC))
  {
     FloatingTextStringOnCreature(sMessage, oPC);
     oPC = GetNextPC();
  }
}

////////////////////////////////////////////////
//PROTOTYPE DEFINED
void GiveDMItems(object oDM)
{
object oWay = GetWaypointByTag("ref_point");
object oBarrel = GetNearestObjectByTag("gen_dm_items", oWay);
object oCopy = GetFirstItemInInventory(oBarrel);
string sTag;
while(GetIsObjectValid(oCopy))
{
 sTag = GetTag(oCopy);
 if(!HasItem(oDM, sTag))
 {
  CopyItem(oCopy, oDM, TRUE);
 }
 oCopy = GetNextItemInInventory(oBarrel);
}

}

///////////////////////////////////////////////////////
//PROTOTYPE DEFINED

void GivePCItems(object oDM)
{
 object oWay = GetWaypointByTag("ref_point");
object oBarrel = GetNearestObjectByTag("gen_start_items", oWay);
object oCopy = GetFirstItemInInventory(oBarrel);
string sTag;
while(GetIsObjectValid(oCopy))
{
 sTag = GetTag(oCopy);
 if(!HasItem(oDM, sTag))
 {
  CopyItem(oCopy, oDM, TRUE);
 }
 oCopy = GetNextItemInInventory(oBarrel);
}
DelayCommand(3.0, ExecuteScript("pc_item_sort", oDM));
}


The OnClientEnter seems to work perfectly - at least as far as I have been able to test. PCs cannot select PrCs on levelup, the class is simply greyed out, as if you do not meet the prerequisite.

However, the second part, I cant get to work. When I pick up one of the tokens and try to levelup, I still can't choose the PrC. I tried relogging with the PC holding the token, but still cannot levelup in the PrC.

Anyone know what I am doing wrong? I am fairly sure it is in my OnAquiredItem script, but not sure? 


OnAquiredItem script: 

/*////////////////////////////////////////////////////////
----------------------------------------------------------
Script Name: gen_pc_acquire
----------------------------------------------------------
Created By: Genisys(Guile)
Created On: 4/23/08
Updated On: 9/09/09
----------------------------------------------------------
This is my premier OnAcquire item Module Event script
It works for Single or Multi Player Mode!!!
----------------------------------------------------------
////////////////////////////////////////////////////////*/

//Required Include
#include "x2_inc_switches"

//Main Script
void main()
{
    //Declar Major variables..
    object oPC = GetModuleItemAcquiredBy();

    if(!GetIsPC(oPC))
    return;

    object oRobbed = GetModuleItemLostBy();
    object oItem = GetModuleItemAcquired();

    //Identify all items on Acquire! '<img'>
    SetIdentified(oItem, TRUE);
    TakeGoldFromCreature(50, oPC, TRUE); //charge them 1/2 price '<img'>

    if(GetPlotFlag(oItem) || GetItemCursedFlag(oItem))
    {
     //All plot items cannot be stolen!
     SetPickpocketableFlag(oItem, FALSE); //Ha!
    }

    object oTaken = GetModuleItemLost();
    string sTaken = GetName(oTaken);
    string sRecieved = GetName(oItem);
    string sRob = GetName(oRobbed);
    string sThief = GetName(oPC);
    int nNew = GetLocalInt(oItem, "ACQUIRED");
    int nDeed = GetItemCursedFlag(oItem);
    string sRobbery;
    string sNotify;
    string sCD = GetPCPublicCDKey(oPC);
    string sOwner = GetLocalString(oItem, "OWNER");
    object oCopy;
    int nPCI = GetLocalInt(oItem, "PCITEM");
    object oBag = GetItemPossessedBy(oPC, "pc_item_contain");

    //Don't Run Script on the DMs!
    if(GetIsDM(oPC))
    return;


    if(nPCI == 1)
    {
     DelayCommand(1.0, SetItemCursedFlag(oItem, TRUE));
    }



sRobbery = "*****ATTENTION******";
sRobbery += sThief;
sRobbery += " Has taken the item - ";
sRobbery += sRecieved;
sRobbery += " from the player - ";
sRobbery += sRob;
sRobbery += " **PLEASE INVESTIGATE!**";

//For log file...
sNotify = "**#####******ATTENTION******#####** - ";
sNotify += sThief;
sNotify += " Might Have Stole - ";
sNotify += sRecieved;
sNotify += " from - ";
sNotify += sRob;

///////////////////////////////////////////////////////////////
//Theft Notification...

//If the items has been aquired by someone before...
if(nNew)
{
//let's make sure that they are in fact NOT the original owner!
if(sCD != sOwner)
{
  //Verify it's a PC & they have pick pocket ranks!
  if(GetIsPC(oPC) && GetIsPC(oRobbed) && GetSkillRank(SKILL_PICK_POCKET, oPC, TRUE) >=1)
  {
   //SetLocalInt(oItem, "ACQUIRED", FALSE); //Prevent repeat error!
   //oCopy = CopyItem(oItem, oRobbed, TRUE); //copy the item back on the PC!
   //DestroyObject(oItem, 0.5f); //kill the one the rogue got!
   //SendMessageToAllDMs(sNotify);
   PrintString(sNotify);
  }
}
}

if(nDeed) //if it's an undroppable item..
{
 if(nNew==FALSE)
 {
  SetLocalInt(oItem, "ACQUIRED", TRUE); //ID the true owner!
  SetLocalString(oItem, "OWNER", sCD); //ID the true owner!
 }
//otherwise someone has stolen it from the player!
else
{
  //Verify they are NOT the original owner!
  if(sCD != sOwner)
  {
    //Verify it's a PC & they have pick pocket ranks!
    if(GetIsPC(oPC) && GetIsPC(oRobbed) && GetSkillRank(SKILL_PICK_POCKET, oPC, TRUE) >=1)
    {
     SetLocalInt(oItem, "ACQUIRED", FALSE); //Prevent repeat error!
     oCopy = CopyItem(oItem, oRobbed, TRUE); //copy the item back on the PC!
     DestroyObject(oItem, 0.5f); //kill the one the rogue got!
     SendMessageToAllDMs(sRobbery);
     PrintString(sRobbery);
    }
  }
}
}

//Prevent some items from being Pickpocketed!
if(GetLocalInt(GetModule(),"PickPocketFix")==1)
       {
       // This will keep the listed item types from being pickpocketable.
       if ((GetBaseItemType(oItem)== (BASE_ITEM_ARMOR||BASE_ITEM_BASTARDSWORD||
       BASE_ITEM_BATTLEAXE||BASE_ITEM_BOOTS||BASE_ITEM_DIREMACE||BASE_ITEM_DOUBLEAXE||
       BASE_ITEM_DWARVENWARAXE||BASE_ITEM_GREATAXE||BASE_ITEM_GREATSWORD||BASE_ITEM_HALBERD||
       BASE_ITEM_HEAVYCROSSBOW||BASE_ITEM_HEAVYFLAIL||BASE_ITEM_HELMET||BASE_ITEM_KATANA||
       BASE_ITEM_LARGESHIELD||BASE_ITEM_LIGHTCROSSBOW||BASE_ITEM_LONGBOW||BASE_ITEM_LONGSWORD||
       BASE_ITEM_MAGICSTAFF||BASE_ITEM_QUARTERSTAFF||BASE_ITEM_RAPIER||BASE_ITEM_SCYTHE||
       BASE_ITEM_SHORTBOW||BASE_ITEM_SMALLSHIELD||BASE_ITEM_TOWERSHIELD||BASE_ITEM_TWOBLADEDSWORD||
       BASE_ITEM_WARHAMMER))||(GetWeight(oItem)>=3))
           {
            SetPickpocketableFlag(oItem, FALSE);
           }
       }


///////////////////////////////////////////////////////////////


//Used to allow PrCs with tokens.

 string tagged = GetTag(oItem);
   if (tagged == "AssassinToken") {
       SetLocalInt(oPC, "X1_AllowAsasin", 0);
   }
   else if (tagged == "ShadowdancerToken") {
       SetLocalInt(oPC, "X1_AllowShadowdancer", 0);
   }
   else if (tagged == "HarperToken") {
       SetLocalInt(oPC, "X1_AllowHarper", 0);
   }
   else if (tagged == "ArcaneArcherToken") {
       SetLocalInt(oPC, "X1_AllowArcher", 0);
   }
   else if (tagged == "BlackguardToken") {
       SetLocalInt(oPC, "X1_AllowBrg", 0);
   }
   else if (tagged == "DivinechampionToken") {
       SetLocalInt(oPC, "X1_AllowDivcha", 0);
   }
   else if (tagged == "WeaponmasterToken") {
       SetLocalInt(oPC, "X1_AllowWM", 0);
   }
   else if (tagged == "PalemasterToken") {
       SetLocalInt(oPC, "X1_AllowPalema", 0);
   }
   else if (tagged == "ShifterToken") {
       SetLocalInt(oPC, "X1_AllowShiftr", 0);
   }
   else if (tagged == "DwarvenDefenderToken") {
       SetLocalInt(oPC, "X1_AllowDwDef", 0);
   }
   else if (tagged == "DragonDiscipleToken") {
       SetLocalInt(oPC, "X1_AllowDrDis", 0);
   }
   else if (tagged == "PurpleDragonKnightToken") {
       SetLocalInt(oPC, "DLA_AllowPDK", 0);
   }
   else {}


//More code should go here...

////////////////////////////////////////////////////////////////

    // * Generic Item Script Execution Code
    // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
    // * it will execute a script that has the same name as the item's tag
    // * inside this script you can manage scripts for all events by checking against
    // * GetUserDefinedItemEventNumber(). See x2_it_example.nss
    if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
    {
       SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACQUIRE);
       int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
       if (nRet == X2_EXECUTE_SCRIPT_END)
       {
          return;
       }

    }

//////////////////////////////////////////////////////
///////////////////////////////
}            //Main Script End
///////////////////////////////
/////////////////////////////////////////////////////


Both scripts compile fine.


Thank you in advance
               
               

               
            

Legacy_Arawan

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Help with blockning PrCs / unbloking with item.
« Reply #1 on: September 21, 2010, 04:20:30 pm »


               Urk the above looks messy.. I hope you can all read it
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Help with blockning PrCs / unbloking with item.
« Reply #2 on: September 21, 2010, 09:44:09 pm »


               It might be a lot easier to do something like this in the modules "OnPlayerLevelUp" event. If the player levels and they have a prestige class but no item to match then they auto de-level and have to re-level. An example might be something like this:


int GetHasclass(object oPC, int iclass)
{
int iclass1 = GetclassByPosition(1, oPC);
int iclass2 = GetclassByPosition(2, oPC);
int iclass3 = GetclassByPosition(3, oPC);
if (iclass == iclass1 || iclass == iclass2 || iclass == iclass3)
return TRUE;
else return FALSE;
}
void main()
{
object oPC = GetPCLevellingUp();
int iXP = GetXP(oPC);
if (
    (GetHasclass(oPC, class_TYPE_ARCANE_ARCHER)==TRUE && GetItemPossessedBy(oPC, "TAG OF ITEM")==OBJECT_INVALID) ||
    (GetHasclass(oPC, class_TYPE_ASSASSIN)==TRUE && GetItemPossessedBy(oPC, "TAG OF ITEM")==OBJECT_INVALID) ||
    (GetHasclass(oPC, class_TYPE_BLACKGUARD)==TRUE && GetItemPossessedBy(oPC, "TAG OF ITEM")==OBJECT_INVALID)
   )
    {
    int iLevel = GetHitDice(oPC);
    int iDelevelXP = (iLevel-1) * (iLevel - 2) * 500;
    SetXP(oPC, iDelevelXP);
    DelayCommand(1.0, SetXP(oPC, iXP));
    SendMessageToPC(oPC, "You have taken a prestige class without possessing the proper token. You must now re-level.");
    }
}


Hope it helps.
               
               

               
            

Legacy_Arawan

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Help with blockning PrCs / unbloking with item.
« Reply #3 on: September 22, 2010, 02:25:58 pm »


               Doesnt that have potential to create problems with some of the bonuses from the prestige classes? Otherwise I think it looks good, but I do rather like the original code for the .. hmm.. simplicity of it?



The only problem with it seems to be I cant get the last bit working with my OnAquire script, properly because of mediocre scripting skills.



I thought it might be possible instead to do a tagbased OnEquip script and then make a corresponding ring, but that didnt seem to work either sadly. the script looked like this:



// Script name: eq_Palemasterring



void main()

{



object oPC = GetPCItemLastEquippedBy();



object oItem;

oItem = GetPCItemLastEquipped();



if (!GetIsPC(oPC)) return;



SetLocalInt(oPC, "X2_AllowPalema", 0);



}



Any chance anyone have an idea on what I am doing wrong, or even better, can see how I fit in the lat bit of code up top in my original post into my OnAquire script?



If not, I might work with your idea GoG. Thanks as always for your aid
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Help with blockning PrCs / unbloking with item.
« Reply #4 on: September 22, 2010, 05:48:43 pm »


               Hi,
Strings don't usually work with "==" in programming languages.  Why don't you try this in your "OnAcquireItem" script:


object oItem = GetModuleItemAcquired();
   object oPC = GetModuleItemAcquiredBy();
   string tagged = GetTag(oItem);

if ( TestStringAgainstPattern("AssassinToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowAsasin", 0);
}
else if (TestStringAgainstPattern("ShadowdancerToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowShadowdancer", 0);
}
else if (TestStringAgainstPattern("HarperToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowHarper", 0);
}
else if (TestStringAgainstPattern("ArcaneArcherToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowArcher", 0);
}
else if (TestStringAgainstPattern("BlackguardToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowBrg", 0);
}
else if (TestStringAgainstPattern("DivinechampionToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowDivcha", 0);
}
else if (TestStringAgainstPattern("WeaponmasterToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowWM", 0);
}
else if (TestStringAgainstPattern("PalemasterToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowPalema", 0);
}
else if (TestStringAgainstPattern("ShifterToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowShiftr", 0);
}
else if (TestStringAgainstPattern("DwarvenDefenderToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowDwDef", 0);
}
else if (TestStringAgainstPattern("DragonDiscipleToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowDrDis", 0);
}
else if (TestStringAgainstPattern("PurpleDragonKnightToken",tagged) ) {
SetLocalInt(oPC, "DLA_AllowPDK", 0);
}
else {}
               
               

               


                     Modifié par Mudeye, 22 septembre 2010 - 04:49 .
                     
                  


            

Legacy_Arawan

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Help with blockning PrCs / unbloking with item.
« Reply #5 on: September 22, 2010, 07:04:02 pm »


               Goddarnit!

I just found the problem.. Thank you mudeye for supplying the new script that made me re-read the entire two scripts.. The problem was in the original scripts I borrowed from the old bioware forums, and I never thought to check them..

The problem was:

OnEnter: SetLocalInt(oPC,"X2_AllowPalema",1);

and in the OnAquire: else if (TestStringAgainstPattern("PalemasterToken",tagged) ) {
SetLocalInt(oPC, "X1_AllowPalema", 0);

Darn me for not proofreading them the first time round.. Sorry all for your time, but thank you very much both GoG and Mudeye for suggestions ':crying:'