moda Posted January 24, 2010 Share Posted January 24, 2010 i cant think of a way to remove 500 chemicals of a character with scripting. i tried a while loop, and remove item script command but it wouldn't registered the chem_00001 item as valid for removal. please helps Link to comment Share on other sites More sharing options...
harIII Posted January 24, 2010 Share Posted January 24, 2010 This should do the job: void main() { object oDestroy = GetFirstItemInInventory( GetFirstPC() ); while( GetIsObjectValid( oDestroy ) ) { if( GetTag( oDestroy ) == "chem_00001" ) DestroyObject( oDestroy, 0.00, FALSE, 0.00 ); oDestroy = GetNextItemInInventory( GetFirstPC() ); } } Link to comment Share on other sites More sharing options...
moda Posted January 24, 2010 Author Share Posted January 24, 2010 but i need to destroy 500 chemicals not 1 Link to comment Share on other sites More sharing options...
harIII Posted January 24, 2010 Share Posted January 24, 2010 It should just keep going through your inventory and if the item matches the tag (in this case chem_00001) and destroys it. Link to comment Share on other sites More sharing options...
moda Posted January 24, 2010 Author Share Posted January 24, 2010 yes but that will destroy all chemicals in my inventory edit heres my current code void main() { object oPC = GetSpellTargetObject(); int nSubtract = 1; int nRand = d3( 1 ); int int3 = 1; int inte = 1; int destroy = 500; object oDestroy = GetFirstItemInInventory( GetFirstPC() ); while( GetIsObjectValid( oDestroy ) ) { if( GetTag( oDestroy ) == "chem_00001" ) if (GetItemStackSize(oDestroy) <= 500) { switch( nRand ) { case 1: AdjustCreatureAttributes( oPC, ABILITY_STRENGTH, nSubtract ); break; case 2: AdjustCreatureAttributes( oPC, ABILITY_DEXTERITY, nSubtract ); break; case 3: AdjustCreatureAttributes( oPC, ABILITY_CONSTITUTION, nSubtract ); break; } switch( nRand ) { case 1: AdjustCreatureAttributes( oPC, ABILITY_STRENGTH, nSubtract ); break; case 2: AdjustCreatureAttributes( oPC, ABILITY_DEXTERITY, nSubtract ); break; case 3: AdjustCreatureAttributes( oPC, ABILITY_CONSTITUTION, nSubtract ); break; } int nRand2 = d3( 1 ); switch( nRand2 ) { case 1: AdjustCreatureAttributes( oPC, ABILITY_WISDOM, -1 ); break; case 2: AdjustCreatureAttributes( oPC, ABILITY_CHARISMA, -1 ); break; case 3: AdjustCreatureAttributes( oPC, ABILITY_INTELLIGENCE, -1 ); break; } while (inte > destroy){ while( GetIsObjectValid( oDestroy ) ) { if( GetTag( oDestroy ) == "chem_00001" ) DestroyObject( oDestroy, 0.00, FALSE, 0.00 ); destroy = destroy -1; oDestroy = GetNextItemInInventory( GetFirstPC() ); } } } } } Link to comment Share on other sites More sharing options...
harIII Posted January 24, 2010 Share Posted January 24, 2010 Try this, I'm not sure if it will compile though void main() { object oDestroy = GetFirstItemInInventory( GetFirstPC() ); int count = 0; while(GetIsObjectValid( oDestroy ) ) { if( count <= 500 && GetTag( oDestroy ) == "chem_00001" ) count++; DestroyObject( oDestroy, 0.00, FALSE, 0.00 ); oDestroy = GetNextItemInInventory( GetFirstPC() ); } } Link to comment Share on other sites More sharing options...
moda Posted January 24, 2010 Author Share Posted January 24, 2010 as you can see my code is a tad heavy on nested statements, but that was the way i learned back in the day Link to comment Share on other sites More sharing options...
harIII Posted January 24, 2010 Share Posted January 24, 2010 For me my philosophy is whatever gets the job done, if it's 10 lines or 100 lines of code, just so long as it does the what you need. Link to comment Share on other sites More sharing options...
moda Posted January 25, 2010 Author Share Posted January 25, 2010 which it doesnt :(/// the logic is flawless it just doesnt work Link to comment Share on other sites More sharing options...
moda Posted January 25, 2010 Author Share Posted January 25, 2010 i tried rewriting it as void main() { object oPC = GetSpellTargetObject(); int nSubtract = 1; int nRand = d3( 1 ); int int3 = 1; object oDestroy = GetFirstItemInInventory( GetFirstPC() ); int count = 0; while(GetIsObjectValid( oDestroy ) ) { if( count <= 500 && GetTag( oDestroy ) == "chem_00001" ) count++; DestroyObject( oDestroy, 0.00, FALSE, 0.00 ); oDestroy = GetNextItemInInventory( GetFirstPC() ); } if(count =500){ switch( nRand ) { case 1: AdjustCreatureAttributes( oPC, ABILITY_STRENGTH, nSubtract ); break; case 2: AdjustCreatureAttributes( oPC, ABILITY_DEXTERITY, nSubtract ); break; case 3: AdjustCreatureAttributes( oPC, ABILITY_CONSTITUTION, nSubtract ); break; } switch( nRand ) { case 1: AdjustCreatureAttributes( oPC, ABILITY_STRENGTH, nSubtract ); break; case 2: AdjustCreatureAttributes( oPC, ABILITY_DEXTERITY, nSubtract ); break; case 3: AdjustCreatureAttributes( oPC, ABILITY_CONSTITUTION, nSubtract ); break; } int nRand2 = d3( 1 ); switch( nRand2 ) { case 1: AdjustCreatureAttributes( oPC, ABILITY_WISDOM, -1 ); break; case 2: AdjustCreatureAttributes( oPC, ABILITY_CHARISMA, -1 ); break; case 3: AdjustCreatureAttributes( oPC, ABILITY_INTELLIGENCE, -1 ); break; } } } but it now just destroys all items in my inventory Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.