ok I need a bit more help not sure why its not retriving data from db
my set item db script:
// itm_exam_set
//
// examines item sets item properties into db
//
///////////////////////////////////////////////////////////////////
#include "grey_item_func"
///////////////////////////////////////////////// //
// these includes are in above include
//#include "nwnx_funcs" this include in grey_item_func
//#include "x2_inc_itemprop" this include in grey_item_func
////////////////////////////////////////////
void main()
{
object oObject= OBJECT_SELF;
object oPC=GetLocalObject(oObject,"Player");
string sDBName="DB_"+GetTag(OBJECT_SELF)+"";
string sNumItems="NumItems";
//item info vars
object oItem;
int iItemNumber=0;//item number // //// //
string sItemResRef;
int iItemNumProp=0;//item property number
itemproperty iItemProp;
string sPropInfo;
///////////////////////////////////////////////////////////////////
//
oItem=GetFirstItemInInventory(OBJECT_SELF);
//item while check
while( GetIsObjectValid (oItem)==TRUE )
{
// set first item to DB
iItemNumber++;
sItemResRef= GetResRef(oItem);
SetCampaignString(sDBName,"Item_"+IntToString( iItemNumber )+"",sItemResRef,oObject);
iItemProp=GetFirstItemProperty(oItem);
//item property while check
while( GetIsItemPropertyValid (iItemProp)==TRUE )
{
iItemNumProp++;
sPropInfo=ItemPropToString (iItemProp);
PrintString("item ResRef="+sItemResRef+" SET funtion string="+sPropInfo+"");
SendMessageToPC( oPC,"item numprop="+IntToString(iItemNumProp)+"" );
SendMessageToPC( oPC,"item ResRef="+sItemResRef+" SET funtion string="+sPropInfo+"" );
// Set items_properties to DB //item prop to string GW
SetCampaignString(sDBName,"Item_"+IntToString( iItemNumber )+"_ItemProp_"+IntToString( iItemNumProp )+"",sPropInfo,oObject);
iItemProp=GetNextItemProperty(oItem);
}//END of item property while check
SetCampaignInt(sDBName,"Item_"+IntToString( iItemNumber )+"_MaxItemProps",iItemNumProp,oObject);
//GetItemPropertyParam1Value
oItem=GetNextItemInInventory(OBJECT_SELF);
}//END of item while check
SetCampaignInt(sDBName,"NumItems", iItemNumber,oObject);
// need to destroy item in object produces
// dubble Items //
INVY_destroyALL_Items(OBJECT_SELF);
////////////////
}// end of script
my get item DB script:
// itm_exam_get
// Gets item data from db
// gets data and creates new item by resref then using DB adds properties to
// new item. Thus allowing retrieving of custom items.
// **NOTE**
// so far will only store item that is in toolset pallet
///////////////////////////////////////////////////////////////////
#include "grey_item_func"
///////////////////////////////////////////////////
// these includes are in above include
//////////////////////////////////////////// //
void main()
{
object oObject= OBJECT_SELF;
object oPC=GetLocalObject(oObject,"Player");
string sDBName="DB_"+GetTag(OBJECT_SELF)+"";
string sNumItems="NumItems";
//item info vars
object oItem;
int iItemNumber=0;//item number
string sItemResRef;
int iItemNumProp=0;//item property number
itemproperty iItemProp;
string sPropInfo;
itemproperty iPropFix;
string ipString;
string sItmCreate; //
itemproperty ipProperty;
///////////////////////////////////////////////////////////////////
int nMaxIndex= GetCampaignInt(sDBName,"NumItems",oObject);
int nIndex;
for (nIndex = 1; nIndex <= nMaxIndex; nIndex++)
{
sItmCreate=GetCampaignString(sDBName,"Item_"+IntToString( nIndex )+"",oObject);
object oItem=CreateItemOnObject(sItmCreate,OBJECT_SELF);
if( GetIsObjectValid (oItem)==TRUE ){
//id and strip item props
//ip_ID_StripItemProps(oItem);
}
if( GetIsObjectValid (oItem)==TRUE )
{
int nMaxIndexProp= GetCampaignInt(sDBName,"Item_"+IntToString( nIndex )+"_MaxItemProps",oObject);
int nIndexProp;
for (nIndexProp = 1; nIndexProp <= nMaxIndex; nIndexProp++)
{
ipString= GetCampaignString(sDBName,"Item_"+IntToString( nIndex )+"_ItemProp_"+IntToString( nIndexProp )+"",oObject );
//debug
PrintString("item ResRef="+sItmCreate+" GET funtion string="+ipString+"");
SendMessageToPC( oPC,"item ResRef="+sItmCreate+" GET funtion string="+ipString+"" );
//debug end
iPropFix= StringToItemProp( ipString ); //
ipProperty = iPropFix;
// add the item props from db
//AddItemProperty( DURATION_TYPE_PERMANENT,ipProperty,oItem);
IPSafeAddItemProperty(oItem,ipProperty,0.0,X2_IP_ADDPROP_POLICY_REPLACE_EXISTING);
}//end of for item props
}//end of if oItem valid
}//end of for number of items
//////////////// //
}// end of script
Please any help would be great, I'm not able to find my errors..
Oh here is the include needed.
///////////////////////////////////////
//
// grey_item_func
//
//
//
////////////////////////////////////////////////
#include "x2_inc_itemprop"
#include "x0_i0_stringlib"
#include "x2_i0_spells"
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//::
//:: Turns Itemproperty to string
//::
string ItemPropToString(itemproperty ipProp);
//---Function ItemPropToString(itemproperty ipProp);
string ItemPropToString(itemproperty ipProp)
{
object oItem;
// to turn the iproptery into a string.
itemproperty ipProperty=ipProp;// = GetFirstItemProperty (oItem);
string sIprop = IntToString (GetItemPropertyType(ipProperty));
sIprop += "|"+ IntToString(GetItemPropertyCostTable(ipProperty));
sIprop += "|"+ IntToString(GetItemPropertyCostTableValue(ipProperty));
sIprop += "|"+ IntToString(GetItemPropertyDurationType (ipProperty));
sIprop += "|"+ IntToString( GetItemPropertyParam1(ipProperty));
sIprop += "|"+ IntToString( GetItemPropertyParam1Value(ipProperty));
sIprop += "|"+ IntToString( GetItemPropertySubType(ipProperty));
return sIprop;
}
//::
//:: Turns string from ItemPropToString(itemproperty ipProp) fuction
//:: into Itemproperty
//::
itemproperty StringToItemProp(string sIprop);
//itemproperty StringToItemProp(int ipRemadeProp,int nPropTabl,int nPropValue,int nDuration,int nPram1,int nPram1Val,int nSubType);
//itemproperty StringToItemProp(int ipRemadeProp);
//---Function StringToItemProp(string sIprop);
itemproperty StringToItemProp(string sIprop)
//itemproperty StringToItemProp(int ipRemadeProp,int nPropTabl,int nPropValue,int nDuration,int nPram1,int nPram1Val,int nSubType)
//itemproperty StringToItemProp(int ipRemadeProp)
{
string sIprop;
// To turn the string back to an Iproperty is going to be harder.
int nPropType =StringToInt( GetTokenByPosition(sIprop,"|",0));
int nPropTabl =StringToInt( GetTokenByPosition(sIprop,"|",1));
int nPropValue=StringToInt( GetTokenByPosition(sIprop,"|",2));
int nDuration =StringToInt( GetTokenByPosition(sIprop,"|",3));
int nPram1 =StringToInt( GetTokenByPosition(sIprop,"|",4));
int nPram1Val =StringToInt( GetTokenByPosition(sIprop,"|",5));
int nSubType =StringToInt( GetTokenByPosition(sIprop,"|",6));
object oNewItem;
itemproperty ipRemadeProp;
switch (nPropType)
{
case ITEM_PROPERTY_ABILITY_BONUS:
ipRemadeProp= ItemPropertyAbilityBonus( nSubType, nPropValue);
break;
case ITEM_PROPERTY_AC_BONUS:
ipRemadeProp = ItemPropertyACBonus( nPropValue);
break;
case ITEM_PROPERTY_AC_BONUS_VS_ALIGNMENT_GROUP:
ipRemadeProp = ItemPropertyACBonusVsAlign( nSubType,nPropValue);
break;
case ITEM_PROPERTY_AC_BONUS_VS_DAMAGE_TYPE:
ipRemadeProp = ItemPropertyACBonusVsDmgType( nSubType,nPropValue);
break;
case ITEM_PROPERTY_AC_BONUS_VS_RACIAL_GROUP:
ipRemadeProp = ItemPropertyACBonusVsRace( nSubType,nPropValue);
break;
case ITEM_PROPERTY_AC_BONUS_VS_SPECIFIC_ALIGNMENT:
ipRemadeProp = ItemPropertyACBonusVsSAlign( nSubType,nPropValue);
break;
case ITEM_PROPERTY_ADDITIONAL:
ipRemadeProp = ItemPropertyAdditional( nPropValue);
break;
case ITEM_PROPERTY_ARCANE_SPELL_FAILURE:
ipRemadeProp = ItemPropertyArcaneSpellFailure( nPropValue);
break;
case ITEM_PROPERTY_ATTACK_BONUS:
ipRemadeProp = ItemPropertyAttackBonus( nPropValue);
break;
case ITEM_PROPERTY_ATTACK_BONUS_VS_ALIGNMENT_GROUP:
ipRemadeProp = ItemPropertyAttackBonusVsAlign(nSubType, nPropValue);
break;
case ITEM_PROPERTY_ATTACK_BONUS_VS_RACIAL_GROUP:
ipRemadeProp = ItemPropertyAttackBonusVsRace( nSubType,nPropValue);
break;
case ITEM_PROPERTY_ATTACK_BONUS_VS_SPECIFIC_ALIGNMENT:
ipRemadeProp = ItemPropertyAttackBonusVsSAlign( nSubType,nPropValue);
break;
case ITEM_PROPERTY_BASE_ITEM_WEIGHT_REDUCTION:
ipRemadeProp = ItemPropertyWeightReduction( nPropValue);
break;
case ITEM_PROPERTY_BONUS_FEAT:
ipRemadeProp = ItemPropertyBonusFeat( nPropValue);
break;
case ITEM_PROPERTY_BONUS_SPELL_SLOT_OF_LEVEL_N:
ipRemadeProp = ItemPropertyBonusLevelSpell( nSubType,nPropValue);
break;
case ITEM_PROPERTY_CAST_SPELL:
ipRemadeProp = ItemPropertyCastSpell( nSubType,nPropValue);
break;
case ITEM_PROPERTY_DAMAGE_BONUS:
ipRemadeProp = ItemPropertyDamageBonus( nSubType,nPropValue);
break;
case ITEM_PROPERTY_DAMAGE_BONUS_VS_ALIGNMENT_GROUP:
ipRemadeProp = ItemPropertyDamageBonusVsAlign( nSubType,nPropValue,nPram1Val);
break;
case ITEM_PROPERTY_DAMAGE_BONUS_VS_RACIAL_GROUP:
ipRemadeProp = ItemPropertyDamageBonusVsRace( nSubType,nPropValue,nPram1Val);
break;
case ITEM_PROPERTY_DAMAGE_BONUS_VS_SPECIFIC_ALIGNMENT:
ipRemadeProp = ItemPropertyDamageBonusVsSAlign( nSubType,nPropValue,nPram1Val);
break;
case ITEM_PROPERTY_DAMAGE_REDUCTION:
ipRemadeProp = ItemPropertyDamageReduction( nSubType,nPropValue);
break;
case ITEM_PROPERTY_DAMAGE_RESISTANCE:
ipRemadeProp = ItemPropertyDamageResistance( nSubType,nPropValue);
break;
case ITEM_PROPERTY_DAMAGE_VULNERABILITY:
ipRemadeProp = ItemPropertyDamageVulnerability( nSubType,nPropValue);
break;
case ITEM_PROPERTY_DARKVISION:
ipRemadeProp = ItemPropertyDarkvision();
break;
case ITEM_PROPERTY_DECREASED_ABILITY_SCORE:
ipRemadeProp = ItemPropertyDecreaseAbility( nSubType,nPropValue);
break;
case ITEM_PROPERTY_DECREASED_AC:
ipRemadeProp = ItemPropertyDecreaseAC( nSubType,nPropValue);
break;
case ITEM_PROPERTY_DECREASED_ATTACK_MODIFIER:
ipRemadeProp = ItemPropertyAttackPenalty( nPropValue);
break;
case ITEM_PROPERTY_DECREASED_DAMAGE:
ipRemadeProp = ItemPropertyDamagePenalty( nPropValue);
break;
case ITEM_PROPERTY_DECREASED_ENHANCEMENT_MODIFIER:
ipRemadeProp = ItemPropertyEnhancementPenalty( nPropValue);
break;
case ITEM_PROPERTY_DECREASED_SAVING_THROWS:
ipRemadeProp = ItemPropertyReducedSavingThrow(nSubType, nPropValue);
break;
case ITEM_PROPERTY_DECREASED_SAVING_THROWS_SPECIFIC:
ipRemadeProp = ItemPropertyReducedSavingThrowVsX(nSubType, nPropValue);
break;
case ITEM_PROPERTY_DECREASED_SKILL_MODIFIER:
ipRemadeProp = ItemPropertyDecreaseSkill( nSubType,nPropValue);
break;
case ITEM_PROPERTY_ENHANCED_CONTAINER_REDUCED_WEIGHT:
ipRemadeProp = ItemPropertyContainerReducedWeight( nPropValue);
break;
case ITEM_PROPERTY_ENHANCEMENT_BONUS:
ipRemadeProp = ItemPropertyEnhancementBonus( nPram1);
break;
case ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_ALIGNMENT_GROUP:
ipRemadeProp = ItemPropertyEnhancementBonusVsAlign( nSubType,nPropValue);
break;
case ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_RACIAL_GROUP:
ipRemadeProp = ItemPropertyEnhancementBonusVsRace(nSubType, nPropValue);
break;
case ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_SPECIFIC_ALIGNEMENT:
ipRemadeProp = ItemPropertyEnhancementBonusVsSAlign( nSubType,nPropValue);
break;
case ITEM_PROPERTY_EXTRA_MELEE_DAMAGE_TYPE:
ipRemadeProp = ItemPropertyExtraMeleeDamageType( nPropValue);
break;
case ITEM_PROPERTY_EXTRA_RANGED_DAMAGE_TYPE:
ipRemadeProp = ItemPropertyExtraRangeDamageType( nPropValue);
break;
case ITEM_PROPERTY_FREEDOM_OF_MOVEMENT:
ipRemadeProp = ItemPropertyFreeAction();
break;
case ITEM_PROPERTY_HASTE:
ipRemadeProp = ItemPropertyHaste();
break;
case ITEM_PROPERTY_HEALERS_KIT:
ipRemadeProp = ItemPropertyHealersKit( nPropValue);
break;
case ITEM_PROPERTY_HOLY_AVENGER:
ipRemadeProp = ItemPropertyHolyAvenger();
break;
case ITEM_PROPERTY_IMMUNITY_DAMAGE_TYPE:
ipRemadeProp = ItemPropertyDamageImmunity(nSubType,nPropValue);
break;
case ITEM_PROPERTY_IMMUNITY_MISCELLANEOUS:
ipRemadeProp = ItemPropertyImmunityMisc( nPropValue);
break;
case ITEM_PROPERTY_IMMUNITY_SPECIFIC_SPELL:
ipRemadeProp = ItemPropertySpellImmunitySpecific( nPropValue);
break;
case ITEM_PROPERTY_IMMUNITY_SPELL_SCHOOL:
ipRemadeProp = ItemPropertySpellImmunitySchool( nPropValue);
break;
case ITEM_PROPERTY_IMMUNITY_SPELLS_BY_LEVEL:
ipRemadeProp = ItemPropertyImmunityToSpellLevel( nPropValue);
break;
case ITEM_PROPERTY_IMPROVED_EVASION:
ipRemadeProp = ItemPropertyImprovedEvasion();
break;
case ITEM_PROPERTY_KEEN:
ipRemadeProp = ItemPropertyKeen();
break;
case ITEM_PROPERTY_LIGHT:
ipRemadeProp = ItemPropertyLight( nSubType,nPropValue);
break;
case ITEM_PROPERTY_MASSIVE_CRITICALS:
ipRemadeProp = ItemPropertyMassiveCritical( nPropValue);
break;
case ITEM_PROPERTY_MATERIAL:
ipRemadeProp = ItemPropertyMaterial( nPropValue);
break;
case ITEM_PROPERTY_MIGHTY:
ipRemadeProp = ItemPropertyMaxRangeStrengthMod( nPropValue);
break;
case ITEM_PROPERTY_MIND_BLANK: //missing
//ipRemadeProp = ItemPropertyACBonus( nPropValue);
break;
case ITEM_PROPERTY_MONSTER_DAMAGE:
ipRemadeProp = ItemPropertyMonsterDamage( nPropValue);
break;
case ITEM_PROPERTY_NO_DAMAGE:
ipRemadeProp = ItemPropertyNoDamage();
break;
case ITEM_PROPERTY_ON_HIT_PROPERTIES:
ipRemadeProp = ItemPropertyOnHitProps( nSubType,nPropValue,nPram1Val);
break;
case ITEM_PROPERTY_ON_MONSTER_HIT:
ipRemadeProp = ItemPropertyOnMonsterHitProperties( nSubType,nPropValue);
break;
case ITEM_PROPERTY_ONHITCASTSPELL:
ipRemadeProp = ItemPropertyOnHitCastSpell( nSubType,nPropValue);
break;
case ITEM_PROPERTY_POISON://missing
//ipRemadeProp = ItemPropertyACBonus( nPropValue);
break;
case ITEM_PROPERTY_QUALITY:
ipRemadeProp = ItemPropertyQuality( nPropValue);
break;
case ITEM_PROPERTY_REGENERATION:
ipRemadeProp = ItemPropertyRegeneration( nPropValue);
break;
case ITEM_PROPERTY_REGENERATION_VAMPIRIC:
ipRemadeProp = ItemPropertyVampiricRegeneration( nPropValue);
break;
case ITEM_PROPERTY_SAVING_THROW_BONUS:
ipRemadeProp = ItemPropertyBonusSavingThrow( nSubType,nPropValue);
break;
case ITEM_PROPERTY_SAVING_THROW_BONUS_SPECIFIC:
ipRemadeProp = ItemPropertyBonusSavingThrowVsX( nSubType,nPropValue);
break;
case ITEM_PROPERTY_SKILL_BONUS:
ipRemadeProp = ItemPropertySkillBonus(nSubType, nPropValue);
break;
case ITEM_PROPERTY_SPECIAL_WALK:
ipRemadeProp = ItemPropertySpecialWalk( nPropValue);
break;
case ITEM_PROPERTY_SPELL_RESISTANCE:
ipRemadeProp = ItemPropertyBonusSpellResistance( nPropValue);
break;
case ITEM_PROPERTY_THIEVES_TOOLS:
ipRemadeProp = ItemPropertyThievesTools( nPropValue);
break;
case ITEM_PROPERTY_TRAP:
ipRemadeProp = ItemPropertyTrap( nSubType,nPropValue);
break;
case ITEM_PROPERTY_TRUE_SEEING:
ipRemadeProp = ItemPropertyTrueSeeing();
break;
case ITEM_PROPERTY_TURN_RESISTANCE:
ipRemadeProp = ItemPropertyTurnResistance( nPropValue);
break;
case ITEM_PROPERTY_UNLIMITED_AMMUNITION:
ipRemadeProp = ItemPropertyUnlimitedAmmo( nPropValue);
break;
case ITEM_PROPERTY_USE_LIMITATION_ALIGNMENT_GROUP:
ipRemadeProp = ItemPropertyLimitUseByAlign( nPropValue);
break;
case ITEM_PROPERTY_USE_LIMITATION_class:
ipRemadeProp = ItemPropertyLimitUseByclass( nPropValue);
break;
case ITEM_PROPERTY_USE_LIMITATION_RACIAL_TYPE:
ipRemadeProp = ItemPropertyLimitUseByRace( nPropValue);
break;
case ITEM_PROPERTY_USE_LIMITATION_SPECIFIC_ALIGNMENT:
ipRemadeProp = ItemPropertyLimitUseBySAlign( nPropValue);
break;
case ITEM_PROPERTY_USE_LIMITATION_TILESET:// missing
//ipRemadeProp = ItemPropertyACBonus( nPropValue);
break;
case ITEM_PROPERTY_VISUALEFFECT:
ipRemadeProp = ItemPropertyVisualEffect( nPropValue);
break;
case ITEM_PROPERTY_WEIGHT_INCREASE:
ipRemadeProp = ItemPropertyWeightIncrease( nPropValue);
break;
/// ect. making a case for each of the 48 or so item properties.
}
/*
int nPropType =StringToInt( GetTokenByPosition(sIprop,"|",0));
int nPropTabl =StringToInt( GetTokenByPosition(sIprop,"|",1));
int nPropValue=StringToInt( GetTokenByPosition(sIprop,"|",2));
int nDuration =StringToInt( GetTokenByPosition(sIprop,"|",3));
int nPram1 =StringToInt( GetTokenByPosition(sIprop,"|",4));
int nPram1Val =StringToInt( GetTokenByPosition(sIprop,"|",5));
int nSubType =StringToInt( GetTokenByPosition(sIprop,"|",6));
//StringToItemProp(ipRemadeProp,nPropTabl,nPropValue,nDuration,nPram1,nPram1Val,nSubType)
*/
//return StringToItemProp(ipRemadeProp,nPropTabl,nPropValue,nDuration,nPram1,nPram1Val,nSubType);
//return ipRemadeProp,nPropTabl,nPropValue,nDuration,nPram1,nPram1Val,nSubType;
return ipRemadeProp;
}
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//:://////////////////////////////////////////////////////////
// ids and strips item of props
void ip_ID_StripItemProps(object oItem);
void ip_ID_StripItemProps(object oItem)
{
object oItem;
if(!GetIdentified(oItem) )
{
SetIdentified(oItem,TRUE);
}
//Get the first itemproperty on oItem
itemproperty ipLoop=GetFirstItemProperty(oItem);
//Loop for as long as the ipLoop variable is valid
while (GetIsItemPropertyValid(ipLoop))
{
//remove all props before newones
RemoveItemProperty(oItem, ipLoop);
//Next itemproperty on the list...
ipLoop=GetNextItemProperty(oItem);
}
}
//
// Destroys all item in object oTarget inventory
void INVY_destroyALL_Items(object oTarget);
void INVY_destroyALL_Items(object oTarget)
{
object oTarget;
object oItem;
oItem =GetFirstItemInInventory(oTarget);
while( GetIsObjectValid(oItem) )
{
DestroyObject(oItem);
oItem =GetNextItemInInventory(oTarget);
}
}
//------------------------------------------------------------------------------
thankyou all in advance
Modifié par Greyfort, 20 février 2011 - 12:04 .