Jump to content

Need a little bit of help overlooking one of my scripts


Recommended Posts

Hey I was just sitting around while I was bored in class and created this script for a bank account.

What I hope this does is:

-has an activator right beside a container. pressing the activator adds all the money in your inventroy into the container

-your container will gather extra money at a rate of 4% per day. this money will get added once a day

-every time you put more money into the container, the interest time restarts

-the container actually has fake gold in it, allowing you to take selective amounts of gold out at a time rather than just grab it all at once

-every moment you are carrying fake gold, it will get transfered into real gold.

 

How does this look?

 

Scn ZBankingAccountScript

Short moneyamount

Short coincount

Float moneyinterest

Float moneyaddition

Float days

Short dailyadd

Ref self ;actually pertains to parent ref

; Starting part handles simply adding gold into parent container upon activation

Begin OnActivate

Set days to 0 ;Resets timer every time you re-access your account

Set self to GetParentRef

Set moneyamount to (player.getitem count gold001)

Player.removeitem gold001 moneyamount

Self.additem goldfake moneyamount

End

; Next part handles accumulation of interest. Once a day adds additional money into the account

Begin Gamemode

Set days to GetSecondsPassed

If dailyadd != GetDayofWeek

Set moneyinterest to (Self.getitemcount goldfake)

Set moneyaddition to ((moneyinterest + (moneyinterest * 0.04 * (days/720)) ;days is divided by 720 because i chose getsecondspassed and there are 720 seconds in an oblivion day

Self.additem goldfake moneyaddition

Set dailyadd to GetDayofWeek

Endif

End

;Last part works with once the player grabs his “money” from the account to turn back into actual money

Begin Gamemode

If player.getitemcount goldfake >= 1

Set coincount to (player.getitemcount goldfake)

Player.removeitem goldfake coincount

Player.additem gold001 coincount

Endif

End

Link to comment
Share on other sites

I actually have been working on a banking mod for quite awhile, and the first thing I would say is that it seems overly complicated, also is there any major reason that you want a proxy money used? the way I do it I just have it as a dialog controlled function, that way you can decide how much money (in specific options) you want to put into your account (which is tracked by a global variable instead of an itemcount) Here's what I use:

 

if CRaccountopen == 1       ; global variable set to 1 when you open the account

if state == 0
set interestdays to gamedayspassed
set state to 1
endif

if state == 1
if gamedayspassed == interestdays + 7
	set interest to CRpersonalaccount *.02        ; short variable for your interest for the period and global variable for your account balance
	set CRpersonalaccount to CRpersonalaccount + interest
	message "Your bank account has yielded interest"
	set state to 0
endif
endif

 

Now mine obviously works over 7 days, but you can change that to 1 if you want it to accumulate every day, and adjust the .02 to .04 for more interest. Also yours has the feature that you want interest to restart whenever the account is accessed. I'd suggest only having that happen when a deposit occurs, if at all, because you cheat yourself out of interest that way.

 

You can always have a "depository" activator and change the short "State" variable above to be a global variable instead and have the depository change the state variable back to 0 if you access it. I'd handle it with an activator that used a menu message box that asks if you want to deposit or withdraw money, and then have a sub message menu for amounts like 500, 1000, 2500, 5000, 10000, 50000, 100000, 500000 which checks for those amounts on the player and carries out the function (or checks the account balance global variable in the case of a withdrawal). If you wanted the interest reset function you just throw in a function to set the state global variable (I'd use a different word as "state" is used by tons of local scripts) back to 0 whenever a deposit or withdrawal is made. Another menu mode option on the activator can be a "check balance" option which basically does a call to display the variable value which I accomplish with a topic from my banker that returns:

 

"messagebox "You have %.0f gold in your account", CRpersonalaccount"

Link to comment
Share on other sites

oh and another problem I have run into is that when you use the "GetDayoftheweek" function it has issues because it recycles from 7 to 1 and can throw some scripts off, which is why I use the getgamedays passed and just modify the interest timer variable off of it. Limiting factor here is it's not as precise as what you are using, but I'm using a 7 day interest cycle, so it's not as important. All in all it seems to work just glancing over it. Have you tried it in game yet? Edited by icecreamassassin
Link to comment
Share on other sites

  • Recently Browsing   0 members

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