Author Topic: Taking a bank deposit fee  (Read 445 times)

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Taking a bank deposit fee
« on: March 22, 2011, 07:19:56 pm »


               In my module I have a banking system set up that records deposits to a database. The process of deposits and  withdrawls that keep a balance to a player character has worked well for years and now I'd like to modify the system to take a 10% fee from the deposit before adding it to the PC's current bank balance. The deposit scripting is as follows:

#include "aps_include"

void main()
{
    int dep=GetLocalInt(OBJECT_SELF, "deposit");
    TakeGoldFromCreature(dep, GetPCSpeaker(), TRUE);
    int balance=GetPersistentInt(GetPCSpeaker(), "cc_bank_gold");
    SetPersistentInt(GetPCSpeaker(), "cc_bank_gold", dep+balance);
    DeleteLocalInt(OBJECT_SELF, "deposit");
}

My questions are: What is the best way and the proper equation for subtracting 10% from the deposit and making that the amount that gets deposited?

Thanks for your help.
               
               

               


                     Modifié par Badwater, 22 mars 2011 - 07:22 .
                     
                  


            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Taking a bank deposit fee
« Reply #1 on: March 22, 2011, 08:08:33 pm »


               Changing the following line:
SetPersistentInt(GetPCSpeaker(), "cc_bank_gold", dep+balance);

-to-

SetPersistentInt(GetPCSpeaker(), "cc_bank_gold", (dep-(dep/10))+balance);

....should be all you need to do.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Taking a bank deposit fee
« Reply #2 on: March 22, 2011, 08:35:55 pm »


               or.
SetPersistentInt(GetPCSpeaker(), "cc_bank_gold", 9*dep/10+balance);
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Taking a bank deposit fee
« Reply #3 on: March 23, 2011, 08:13:00 am »


               Thank you for both of the responses, much appreciated! '<img'>