Aller au contenu

Photo

Taking a bank deposit fee


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
Badwater

Badwater
  • Members
  • 113 messages
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 .


#2
Thayan

Thayan
  • Members
  • 244 messages
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.

#3
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
or.
SetPersistentInt(GetPCSpeaker(), "cc_bank_gold", 9*dep/10+balance);

#4
Badwater

Badwater
  • Members
  • 113 messages
Thank you for both of the responses, much appreciated! :)