Jump to content
  • 0
Sign in to follow this  
cumbe11

tax system for guild

Question

I have this script that calculates 10% of the store sales and divides them equally among the leaders of guilds that own castles registered in the NPC. It works very well; however, the only issue is that if the same guild owns more than one castle, the system doesn't divide the tax correctly, granting only one portion of the division, even if the guild owns two castles, for example.

 

 

Edited by cumbe11

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

vc pode atingir isso modificando o for para  passar por todos os castelos e vendo a qual guild pertencem.

ai na hora de "pagar" o jogador, vai multiplicar pela quantidade de vezes que a guild dele aparece (ou seja, quantos castelos possui), acho que é isso.

 

OnBuyItem:
	set .@TotalCost,0;
	// Calcula o custo total
	for(set .@i,0; .@i < getarraysize( @bought_nameid ); set .@i,.@i+1)
		for(set .@j,0; .@j < getarraysize( .Items ); set .@j,.@j+1)
			if( .Items[.@j] == @bought_nameid[.@i] )
			set .@TotalCost,.@TotalCost + ( .Costs[.@j] * @bought_quantity[.@i] );
	if( #CASHPOINTS >= .@TotalCost ){
		// Deduz #CASHPOINTS e Ganha Itens.
		set #CASHPOINTS,#CASHPOINTS - .@TotalCost;
		for(set .@i,0; .@i < getarraysize( @bought_nameid ); set .@i,.@i+1)
			getitem @bought_nameid[.@i],@bought_quantity[.@i];
			
		// Atribui a quantia de imposto igualmente a outras Guildas.
		for( set .@i,0; .@i < getarraysize( .CastleMap$ ); set .@i,.@i + 1 ) {
			set .@castleGuild, getguildid(getguildname(getcastledata(.CastleMap$[.@i],1)));
			set .@guildCastles, 0; // Counter for guild-owned castles
			// Count guild-owned castles
			for( set .@j, 0; .@j < getarraysize(.CastleMap$); set .@j, .@j + 1) {
				if(getguildid(getguildname(getcastledata(.CastleMap$[.@j],1))) == .@castleGuild) {
					set .@guildCastles, .@guildCastles + 1;
				}
			}
			// distriubir imposto igualmente
			setd( "$GuildTax_"+.@i ),getd( "$GuildTax_"+.@i ) + ( (( .@TotalCost * .TaxRate ) / 100 ) / .@guildCastles );
		}
		
		// Notificação sobre o Total de Imposto Recebido pela Guilda.
		message strcharinfo(0),"Imposto recolhido: "+(( .@TotalCost * .TaxRate ) / 100 )+" Cash";
	}else{
		mes "Você não tem #CASHPOINTS suficiente...";
	}
	close;

 

Share this post


Link to post
Share on other sites
  • 0



dar erro de sinxtax

[Error]:  Loading NPC file: npc/strikero/tax.txt
script error on npc/strikero/tax.txt line 71
    parse_line: need ';'
    66 :                for(set .@i,0; .@i < getarraysize( @bought_nameid ); set .@i,.@i+1)
    67 :                        getitem @bought_nameid[.@i],@bought_quantity[.@i];
    68 :
    69 :                // Atribui a quantia de imposto igualmente a outras Guildas.
    70 :                for( set .@i,0; .@i < getarraysize( .CastleMap$ ); set .@i,.@i + 1 ) {
*   71 :                        set .@castleGuild, getguildid'('getguildname(getcastledata(.CastleMap$[.@i],1)));
    72 :                        set .@guildCastles, 0; // Counter for guild-owned castles
    73 :                        // Count guild-owned castles
    74 :                        for( set .@j, 0; .@j < getarraysize(.CastleMap$); set .@j, .@j + 1) {
    75 :                                if(getguildid(getguildname(getcastledata(.CastleMap$[.@j],1))) == .@castleGuild) {
    76 :                                        set .@guildCastles, .@guildCastles + 1;
 

 

Edited by cumbe11

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.