From 5994a28a51deb506df694364c275ce25fca6cf03 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 2 Sep 2019 16:58:56 -0300 Subject: Ask for a tax of 0.05% when selling items --- npc/012-1/shoppakep.txt | 6 ++++++ npc/012-2/melina.txt | 5 +++++ npc/012-3/alan.txt | 5 +++++ npc/012-5/nicholas.txt | 5 +++++ npc/functions/politics.txt | 20 ++++++++++++++++++++ 5 files changed, 41 insertions(+) diff --git a/npc/012-1/shoppakep.txt b/npc/012-1/shoppakep.txt index a55e36554..5da112f34 100644 --- a/npc/012-1/shoppakep.txt +++ b/npc/012-1/shoppakep.txt @@ -76,4 +76,10 @@ OnBuyItem: debugmes("Purchase confirmed"); PurchaseTaxes("Hurns"); end; + +OnSellItem: + debugmes("Sale confirmed"); + SaleTaxes("Hurns"); + end; } + diff --git a/npc/012-2/melina.txt b/npc/012-2/melina.txt index 83e78b578..ac183a9a6 100644 --- a/npc/012-2/melina.txt +++ b/npc/012-2/melina.txt @@ -65,4 +65,9 @@ OnBuyItem: PurchaseTaxes("Hurns"); end; +OnSellItem: + debugmes("Sale confirmed"); + SaleTaxes("Hurns"); + end; + } diff --git a/npc/012-3/alan.txt b/npc/012-3/alan.txt index 6ec713590..d25531bbf 100644 --- a/npc/012-3/alan.txt +++ b/npc/012-3/alan.txt @@ -133,4 +133,9 @@ OnBuyItem: PurchaseTaxes("Hurns"); end; +OnSellItem: + debugmes("Sale confirmed"); + SaleTaxes("Hurns"); + end; + } diff --git a/npc/012-5/nicholas.txt b/npc/012-5/nicholas.txt index c6043e786..b1a6073e4 100644 --- a/npc/012-5/nicholas.txt +++ b/npc/012-5/nicholas.txt @@ -253,4 +253,9 @@ OnClock1801: OnBuyItem: PurchaseTaxes("Hurns"); end; + +OnSellItem: + debugmes("Sale confirmed"); + SaleTaxes("Hurns"); + end; } diff --git a/npc/functions/politics.txt b/npc/functions/politics.txt index 322cdb654..1c983e8d9 100644 --- a/npc/functions/politics.txt +++ b/npc/functions/politics.txt @@ -44,6 +44,26 @@ function script PurchaseTaxes { return; } +// Proccess Taxes from sales (5% from purchase tax) +// SaleTaxes( Location ) +function script SaleTaxes { + .@tax=0; + for (.@i=0; .@i < getarraysize(@sold_nameid); .@i++) { + // Note: Some NPC might not + .@price=getiteminfo(@sold_nameid[.@i], ITEMINFO_SELLPRICE); + .@tax+=.@price*@sold_quantity[.@i]; + } + .@loc$=strtoupper(getarg(0, LOCATION$)); + .@vat=getd("$"+.@loc$+"_TAX"); + .@vat=.@vat/20; // Only 5% of purchase tax, this is often 0.05% + .@tax=.@tax*.@vat/10000; + if (.@tax) { + debugmes "Sale: %s paid %d in taxes to %s prefecture!", strcharinfo(0), .@tax, .@loc$; + setd("$"+.@loc$+"_TAX", .@vat+.@tax); + } + return; +} + - script Politics NPC_HIDDEN,{ OnSun0000: -- cgit v1.2.3-60-g2f50