Jump to content

Need help with script.


Force70

Recommended Posts

I'm trying to update the script for my mod Coins of Tamriel. Making it to where it no longer removes the coins when you pick them, but also making it to where it tricks the player into thinking that they are spending those coins. What I want to do is have all three coins run by the script copper, silver and gold, to where when you pick them up you gain a set amount of septims (I already have this part).

 

Now. What I need is a script that checks the coins that the player has in his/her inventory. So if the player spends septims it will then remove the correct amount of the proper coin. based on the amount removed, amount in inventory and the coin priority. Which is the following

 

Gold

Silver

Copper

 

Here is the script that I have so far.

 

 

 

Scriptname CoinsofTamriel extends referencealias



Miscobject Property gold001 auto
Miscobject Property gold002 auto
Miscobject Property gold003 auto
Miscobject Property gold004 auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
  if (akBaseItem as miscobject) == gold002;checks to see if the added item is a Copper coin. 
      getactorreference().additem(gold001, (aiItemCount * 1),true)
  endif


  if (akBaseItem as miscobject) == gold003;checks to see if the added item is a Silver coin.
      getactorreference().additem(gold001, (aiItemCount * 50),true)
  endif
 
if (akBaseItem as miscobject) == gold004;checks to see if the added item is a gold coin.
      getactorreference().additem(gold001, (aiItemCount * 100),true)
  endif
endEvent


Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
if (akBaseItem as miscobject) == gold002;checks to see if the added item is a Copper coin. 
      getactorreference().additem(gold001, (aiItemCount * 1),true)
  endif 

if (akBaseItem as miscobject) == gold003;checks to see if the removed item is a silver coin. 
      getactorreference().removeitem(gold001, (aiItemCount * 50),true)
  endif


  if (akBaseItem as miscobject) == gold004;checks to see if the removed item is a gold coin.
      getactorreference().removeitem(gold001, (aiItemCount * 100),true)
  endif
endEvent

 

 

 

So far I have it to where if the player picks up or drops one of the new coins it will remove or add the correct amount of septims from their inventory. What I need now is that if you remove a certain amount of septims from your inventory it will remove the correct amount and the correct coin from your inventory. I'm guessing I'm going to need to have global variables. But I just don't know how to make what I want happen. I'm not a scripter. This script was created for me. I just modified it to make it to where if you drop the coins it will remove septims from your inventory.

 

I'll try and give some examples

.

If player removes/spends 1-50 Septims from their inventory it will check to see if the player has either copper or silver. If the player has silver that will take higher priority over the copper and there for shall be removed, if the player doesn't have silver the script will then remove the correct value of copper.

 

If the player removes 1-100 Septims from their inventory it will check to see if the player has either copper, silver or gold. If the player has gold that will take higher priority over the copper and there for shall be removed, if the player doesn't have gold the script will then check to see if the player has silver, if found it will then remove the correct amount. If the player does have silver but not the correct amount, like if you have 100 septims but its 50 coppers and 1 silver it will removes both the silver and the 50 coppers. Now if the player has 135 septims and the spend 100 of that, and again they don't have a gold coin or 2 silver but instead have 1 silver and 85 coppers, the script will remove the correct value from both so it will remove the 1 silver and 50 coppers while leaving 35 coppers.

 

Now if the player has only a silver coin which equals to 50 Septims and the spend some of it, lets say 30 Septims. The game will remove the silver and then add in the correct number of copper in this case 20 to the player.

 

Now if the player spent all of the coin then it would just remove the silver.

If the player doesn't have silver but only copper it will remove the correct number of copper coins from the players inventory.

 

Lets say the Player has 100 copper, 2 silver and 2 gold. which = to 400 Septims. And the player spends 100 Septims. The script will then check the players inventory to see what coins in needs to remove based on the amount of Septims were removed. So since the player has 2 gold coins the script will remove 1 of them. But if the player didn't have gold it would then go to the next highest item on the list which is silver and remove the correct amount there, which would be 2 silver coins. If the player only had 1 silver coin and 100 copper coins it would remove 1 silver and 50 copper. If the player didn't have any silver or gold coins it would then move to copper which the player has 100 and then would remove 100 copper.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...