Huglarh Posted July 21, 2011 Author Share Posted July 21, 2011 You have to have it similar to this if you want them to only have one at a time. If (Player.GetItemCount SwordToken >= 1) Player.RemoveItemNS SwordToken 99999 ;makes sure they don't have any left Player.AddItemNS SwordToken 1 ;the NS part means no spam, as in no message in the top right EndIf End Also, the C isn't capitalized :whistling: *the "i" is a typo* I put this in after Onequip or OnUnequip? Link to comment Share on other sites More sharing options...
Deleted1848331User Posted July 21, 2011 Share Posted July 21, 2011 (edited) scn SwordTokenScript float defaultEXP float newEXP Begin onAdd Player If Player.GetItemCount SwordToken == 0 Set defaultEXP to getSkillUseIncrementC 14 Set newEXP to defaultEXP*1.5 ; Increase by 50% SetSkillUseIncrementC newEXP 14 ElseIf Player.GetItemCount SwordToken >= 1 Player.RemoveItemNS SwordToken 99999 Player.AddItemNS SwordToken 1 EndIf End Begin OnDrop Player If Player.GetItemCount SwordToken == 1 SetSkillUseIncrementC defaultEXP 14 EndIf End Could probably do it like that. I don't know what you're doing with the onequip part though :P Edited July 21, 2011 by Guest Link to comment Share on other sites More sharing options...
fg109 Posted July 21, 2011 Share Posted July 21, 2011 (edited) I looked over the script again and decided it wouldn't work out very well. It's best to have a quest script store a variable or else have a global variable so it's value will stay the same no matter which token is looking at it: bHasSkillExpChanged14 scn examplescript float defaultEXP float newEXP short IChangedItItWasAllMeMEMEME Begin OnAdd if (bHasSkillExpChanged14) RemoveMe else set defaultEXP to GetSkillUseIncrementC 14 set newEXP to defaultEXP * 1.5 SetSkillUseIncrementC newEXP 14 set IChangedItItWasAllMeMEMEME to 1 set bHasSkillExpChanged14 to 1 endif Begin OnDrop if (IChangedItItWasAllMeMEMEME) SetSkillUseIncrementC defaultEXP 14 set bHasSkillExpChanged14 to 0 endif End Edited July 21, 2011 by fg109 Link to comment Share on other sites More sharing options...
forli Posted July 21, 2011 Share Posted July 21, 2011 (edited) @fg109We should completely avoid using variables to store this information.Also "RemoveMe" act like "RemoveItem ID 1", removing a random item, since inventory items doesn't have references.From the CS.Elderscrolls:If there are multiple items of the same type in the same container, the one that actually gets removed may be first one in the container instead of the one that actually called this function.What happen if the script remove the first token? (the one that give the bonus)The player ends by owning an ineffective token, and you have to drop and take it back to make it work. About the new problem:Mmmh....http://www.thenexusforums.com/public/style_emoticons/dark/psyduck.gif He say the token is removed just after he pick it up. This mean that this:Player.GetItemCount SwordToken == 0 isn't true. So using this code: Begin onAdd Player If Player.GetItemCount SwordToken == 0 Set defaultEXP to getSkillUseIncrementC 14 Set newEXP to defaultEXP*1.5 ; Increase by 50% SetSkillUseIncrementC newEXP 14 ElseIf Player.GetItemCount SwordToken >= 1 Player.RemoveItemNS SwordToken 99999 Player.AddItemNS SwordToken 1 EndIf End Will cause the item to be continuously added and removed until the doomsday...http://www.thenexusforums.com/public/style_emoticons/dark/nuke.gifI can't remember if the "OnAdd" and "OnDrop" events fire just before or just after the item is Added/Removed... Edited July 21, 2011 by forli Link to comment Share on other sites More sharing options...
fg109 Posted July 21, 2011 Share Posted July 21, 2011 (edited) Then I guess there should be 2 global variables: NumTokensInUse14 and defaultEXP14 scn SwordTokenScript float newEXP Begin OnAdd set NumTokensInUse14 to NumTokensInUse14 + 1 if (NumTokensInUse14 == 1) set defaultEXP14 to GetSkillUseIncrementC 14 set newEXP to defaultEXP14 * 1.5 SetSkillUseIncrementC newEXP 14 else RemoveMe endif End Begin OnDrop if (NumTokensInUse14 == 1) SetSkillUseIncrementC defaultEXP14 14 endif set NumTokensInUse14 to NumTokensInUse14 - 1 End This should take care of things even if the player cheats and adds tokens to an NPC. Edited July 21, 2011 by fg109 Link to comment Share on other sites More sharing options...
forli Posted July 21, 2011 Share Posted July 21, 2011 (edited) Then I guess there should be 2 global variables: NumTokensInUse14 and defaultEXP14 scn SwordTokenScript float newEXP Begin OnAdd set NumTokensInUse14 to NumTokensInUse14 + 1 if (NumTokensInUse14 == 1) set defaultEXP14 to GetSkillUseIncrementC 14 set newEXP to defaultEXP14 * 1.5 SetSkillUseIncrementC newEXP 14 else RemoveMe endif End Begin OnDrop if (NumTokensInUse14 == 1) SetSkillUseIncrementC defaultEXP14 14 endif set NumTokensInUse14 to NumTokensInUse14 - 1 End This should take care of things even if the player cheats and adds tokens to an NPC. waitwaitwaitWAITWAIT!! This cause you to get the bonus even if the token is added to NPC or Containers!I'm asking the "GetItemCount inside OnAdd block" problem to other peoples. Soon or later they will give me an answer. Edited July 21, 2011 by forli Link to comment Share on other sites More sharing options...
forli Posted July 21, 2011 Share Posted July 21, 2011 (edited) It seems that OnAdd and OnDrop fire AFTER the item is added/removed.So GetItemCount change this way for both blocks: scn SwordTokenScript float defaultEXP float newEXP Begin onAdd Player If (Player.GetItemCount SwordToken == 1) ; How many items you have. INCLUDE THIS Set defaultEXP to getSkillUseIncrementC 14 Set newEXP to defalutEXP * 1.5 SetSkillUseIncrementC newEXP 14 Else Player.RemoveItem SwordToken 1 EndIf End Begin OnDrop Player If (Player.GetItemCount SwordToken == 0) ; How many items you have. EXCLUDE THIS SetSkillUseIncrementC defaultEXP 14 EndIf End - This way Tokens aren't linked to the bonus (Removing the Token which gave the bonus won't cause the bonus to get removed, if you have other tokens)- Bonus only apply when the Token is in the Player inventory.- Avoid the use of counters, which can fail when you add/remove more items at once. Also if we remove this part: Else Player.RemoveItem SwordToken 1 - There's no risk to CTD (removing an item in the same frame it has been added can cause CTD)- We could keep the other tokens. They will be ineffective but we can sell them (As you do with hammers when you're Master Armorer) Edited July 21, 2011 by forli Link to comment Share on other sites More sharing options...
Huglarh Posted July 21, 2011 Author Share Posted July 21, 2011 (edited) It seems that OnAdd and OnDrop fire AFTER the item is added/removed.So GetItemCount change this way for both blocks: scn SwordTokenScript float defaultEXP float newEXP Begin onAdd Player If (Player.GetItemCount SwordToken == 1) ; How many items you have. INCLUDE THIS Set defaultEXP to getSkillUseIncrementC 14 Set newEXP to defalutEXP * 1.5 SetSkillUseIncrementC newEXP 14 Else Player.RemoveItem SwordToken 1 EndIf End Begin OnDrop Player If (Player.GetItemCount SwordToken == 0) ; How many items you have. EXCLUDE THIS SetSkillUseIncrementC defaultEXP 14 EndIf End - This way Tokens aren't linked to the bonus (Removing the Token which gave the bonus won't cause the bonus to get removed, if you have other tokens)- Bonus only apply when the Token is in the Player inventory.- Avoid the use of counters, which can fail when you add/remove more items at once. Also if we remove this part: Else Player.RemoveItem SwordToken 1 - There's no risk to CTD (removing an item in the same frame it has been added can cause CTD)- We could keep the other tokens. They will be ineffective but we can sell them (As you do with hammers when you're Master Armorer) So, This script will work. Anyone can pick up the token and keep it until they decide to drop it or store it away, And recieve the benefit properly when they keep it in their inventory, then lose the benefit properly when they drop or remove it? Edit:Cause we can work on dropped Tokens from defeat npcs that give temporary 2.0x for a brief time some other time my friend :) We just gotta work on getting this script working with a version of ones you can obtain see in your inventory and freely drop, etc. Edited July 21, 2011 by Huglarh Link to comment Share on other sites More sharing options...
forli Posted July 21, 2011 Share Posted July 21, 2011 So, This script will work. Anyone can pick up the token and keep it until they decide to drop it or store it away, And recieve the benefit properly when they keep it in their inventory, then lose the benefit properly when they drop or remove it?Before saying "This work" you have to test it. If still there's something wrong, add some debug messages: (EXAMPLES) "First token added. Bonus added", "Another token added", "Last token removed. Bonus removed" Link to comment Share on other sites More sharing options...
fg109 Posted July 21, 2011 Share Posted July 21, 2011 @forli Are you sure that counters don't work well if more than 1 item is added at once? Well, I guess it's OK as long as GetItemCount works the way you say it does. You should still make defaultEXP a global variable or store it in a quest script though. Otherwise, if the last token to be removed wasn't the one that set the skill use exp, then defaultEXP would be 0. Link to comment Share on other sites More sharing options...
Recommended Posts