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
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() );
}
}
but i need to destroy 500 chemicals not 1
It should just keep going through your inventory and if the item matches the tag (in this case chem_00001) and destroys it.
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() );
}
}
}
}
}
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() );
}
}
as you can see my code is a tad heavy on nested statements, but that was the way i learned back in the day
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.
which it doesnt :(/// the logic is flawless it just doesnt work
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