Jump to content
  • 0

NPC SHOP


Question

Posted (edited)

E ae galera blz? estou com um 1 npc aqui, e queria editar ele para de vez usar itens como moeda usar zeny. o valor padrao seria 1 zeny, ou seja eu quero que ele use o valor normal citado na configuração  setarray

e tambem queria adicionar um

OnSellItem

onde todos que comprar e vender os itens o npc grava em 1 variavel 10% do valor.

segue o npc:

Spoiler

//  ______________________________________________________________________
// /                                                                      \
// |            _           _   _   _                                      |
// |           | |__  _ __ / \ | |_| |__   ___ _ __   __ _                 |
// |           | '_ \| '__/ _ \| __| '_ \ / _ \ '_ \ / _` |                |
// |           | |_) | | / ___ \ |_| | | |  __/ | | | (_| |                |
// |           |_.__/|_|/_/   \_\__|_| |_|\___|_| |_|\__,_|                |
// |                                                                       |
// |                         brAthena Script                               |
// |-----------------------------------------------------------------------|
// | Nome do Script: Dynamic Shop                                          |
// |-----------------------------------------------------------------------|
// | Criado por: eA/brA Dev. Team                                          |
// |-----------------------------------------------------------------------|
// | Versão brA: 1.1                                                       |
// |-----------------------------------------------------------------------|
// | Descrição:                                                            |
// | Um NPC que vende seus itens por um outro item determinado pelo ADM    |
// |-----------------------------------------------------------------------|
// | Changelog:                                                            |
// | [brA]Floozie [Criador]                                                |
// \_______________________________________________________________________/
prontera,147,175,5	script	Item Trader	822,{

set .@n$, "[ ^cc0000Item Trader^000000 ]";

mes .@n$;
mes "Olá, "+strcharinfo(0)+" !";
mes "O que você gostaria de fazer ?";
next;
if(getgmlevel() >= 80){
	set .@menu$, select("Editar Item de Troca","Comprar Itens","Sair");
} else {
	set .@menu$, select("","Comprar Itens","Sair");
}
switch(.@menu$){

	case 1:
		mes .@n$;
		mes "Digite o ID do item que será";
		mes "a moeda de troca do NPC";
		next;
		input .@itemoeda;
		mes .@n$;
		mes "Tem certeza que deseja trocar por :";
		mes getitemname(.@itemoeda);
		next;
		if(select("Sim:Não") == 2) close;
		set $itemtrade, .@itemoeda;
		mes .@n$;
		mes "Item editado com sucesso !";
		close;
		
	case 2:
		mes .@n$;
		mes "Para comprar seus donates você";
		mes "precisa ter "+getitemname($itemtrade);
		close2;
		callshop "Trader_Item",1;
		npcshopattach "Trader_Item";
		dispbottom "Você possui "+countitem($itemtrade)+" "+getitemname($itemtrade)+"('s)";
		end;
		
	case 3:
		close;

}

OnBuyItem:
for(set @i,0;@i < getarraysize(@bought_nameid);set @i,@i+1){
	for(set @b,0;@b < getarraysize($itens);set @b,@b+2){
		if($itens[@b] == @bought_nameid[@i]){
			set @valor,($itens[(@b+1)]*@bought_quantity[@i]);
			set @valortotal,(@valortotal+@valor);
			break;
		}
	}
}
if(@valortotal > countitem($itemtrade)){
	dispbottom "Você não possui "+getitemname($itemtrade)+" suficientes.";
}
else {
	for(set @i,0;@i < getarraysize(@bought_nameid);set @i,@i+1){
		getitem @bought_nameid[@i],@bought_quantity[@i];
	}
	delitem $itemtrade,@valortotal;
	dispbottom "Obrigado pela compra.";
}
set @valortotal,0;
deletearray @bought_nameid[0],127;
deletearray @bought_quantity[0],127;
end;

OnInit:
npcshopdelitem "Trader_Item",909;
//== Configure os itens sendo 'iditem,preço'
setarray $itens[0],501,1,502,1,503,1,504,1,505,1,506,1,507,1;
for(set .@i,0;.@i < getarraysize($itens);set .@i,.@i+2){
npcshopadditem "Trader_Item",$itens[.@i],$itens[(.@i+1)];
}
}

-	shop	Trader_Item	139,909:-1

 

 

Talbem tem esse outro que eu tentei adaptar mas nao obtive sucesso.

Spoiler

//  _______________________________________________________
// /                                                       \
// |       _           _   _   _                            |
// |      | |__  _ __ / \ | |_| |__   ___ _ __   __ _       |
// |      | '_ \| '__/ _ \| __| '_ \ / _ \ '_ \ / _` |      |
// |      | |_) | | / ___ \ |_| | | |  __/ | | | (_| |      |
// |      |_.__/|_|/_/   \_\__|_| |_|\___|_| |_|\__,_|      |
// |                                                        |
// |                 brAthena Script                        |
// |--------------------------------------------------------|
// | Nome do Script: Loja Dinâmica                          |
// |--------------------------------------------------------|
// | Criado por: Henrique (lockershak / Hold)               |
// |--------------------------------------------------------|
// | Versões eA/brA: todas/todas                            |
// |--------------------------------------------------------|
// | Descrição: Loja dinâmica onde o jogador pode gastar    |
// | items como moeda de troca.                             |
// |--------------------------------------------------------|
// | Changelog: 1.0 - Desenvolvido script inicial. [Hold]   |
// |                                                        |
// \_______________________________________________________/

prontera,164,172,4	script	Loja Dinâmica	770,{

	callshop "d_shop01",1;
	npcshopattach "d_shop01";
	end;
	
	OnBuyItem: {
		set @loops, 0;
		while (@loops < getarraysize (@bought_nameid)) {
			set @loops2, 0;
			while (@loops2 < getarraysize (.items)) {
				if (@bought_nameid[@loops] == .items[@loops2]) {
					set @total_prize, @total_prize + @bought_quantity[@loops] * .items[@loops2+1];
					set @loops2, @loops2+2;
				} else {
					set @loops2, @loops2+2;
				}
			}
			set @loops, @loops+1;
		}
		if (@total_prize > countitem (.coin)) {
			message strcharinfo (0),"Você não possui Moedas de Ouro suficientes.";
			deletearray @bought_quantity, getarraysize(@bought_quantity);
			deletearray @bought_nameid, getarraysize(@bought_nameid);
			set @total_prize, 0;
			end;
		} else {
			set @loops, 0;
			set @weight1, getarraysize (@bought_nameid);
			set @weight2, 0;
			while (@loops < getarraysize (@bought_nameid)) {
				if (checkweight(@bought_nameid[@loops],@bought_quantity[@loops]) == 1) {
					set @weight2, @weight2+1;
					set @loops, @loops+1;
				} else {
					set @loops, @loops+1;
				}
			}
			if (@weight2 == @weight1) {
				set @loops, 0;
				while (@loops < getarraysize (@bought_nameid)) {
					getitem @bought_nameid[@loops],@bought_quantity[@loops];
					set @loops, @loops+1;
				}
				message strcharinfo (0),"Compra efetuada com sucesso.";
				delitem .coin,@total_prize;
				dispbottom "Você gastou "+@total_prize+" Moedas de Ouro, "+countitem (.coin)+" Moedas restantes.";
				deletearray @bought_quantity, getarraysize(@bought_quantity);
				deletearray @bought_nameid, getarraysize(@bought_nameid);
				set @total_prize, 0;
				end;
			} else {
				message strcharinfo (0),"Você está muito pesado.";
				deletearray @bought_quantity, getarraysize(@bought_quantity);
				deletearray @bought_nameid, getarraysize(@bought_nameid);
				set @total_prize, 0;
				end;
			}
		}
	}
	
	OnInit: {
		set .coin, 671; //Item que vai ser utilizado como moeda de troca
		
		setarray .items[0],12202,2,12203,2,12204,2,12205,2,12206,2,12207,2; //DB de preços do NPC
	}
}

-	shop	d_shop01	-1,12202:2,12203:2,12204:2,12205:2,12206:2,12207:2 // Loja que será exibida para o jogador

 

 

Grato.

Edited by clold157

2 answers to this question

Recommended Posts

  • 0
Posted

callshop "d_shop01",1;
npcshopattach "d_shop01";
end;

OnBuyItem: {
    set @loops, 0;
    while (@loops < getarraysize (@bought_nameid)) {
        set @loops2, 0;
        while (@loops2 < getarraysize (.items)) {
            if (@bought_nameid[@loops] == .items[@loops2]) {
                set @total_prize, @total_prize + @bought_quantity[@loops] * .items[@loops2+1];
                set @loops2, @loops2+2;
            } else {
                set @loops2, @loops2+2;
            }
        }
        set @loops, @loops+1;
    }
    if (@total_prize > getarraysize (.coin)) {
        message strcharinfo (0),"Você não possui Zeny suficientes.";
        deletearray @bought_quantity, getarraysize(@bought_quantity);
        deletearray @bought_nameid, getarraysize(@bought_nameid);
        set @total_prize, 0;
        end;
    } else {
        set @loops, 0;
        set @weight1, getarraysize (@bought_nameid);
        set @weight2, 0;
        while (@loops < getarraysize (@bought_nameid)) {
            if (checkweight(@bought_nameid[@loops],@bought_quantity[@loops]) == 1) {
                set @weight2, @weight2+1;
                set @loops, @loops+1;
            } else {
                set @loops, @loops+1;
            }
        }
        if (@weight2 == @weight1) {
            set @loops, 0;
            while (@loops < getarraysize (@bought_nameid)) {
                getitem @bought_nameid[@loops],@bought_quantity[@loops];
                set @loops, @loops+1;
            }
            message strcharinfo (0),"Compra efetuada com sucesso.";
            delitem .coin,@total_prize;
            dispbottom "Você gastou "+@total_prize+" Zeny, "+getarraysize (.coin)+" Zeny restantes.";
            deletearray @bought_quantity, getarraysize(@bought_quantity);
            deletearray @bought_nameid, getarraysize(@bought_nameid);
            set @total_prize, 0;
            end;
            
            // Gravar 10% do valor da compra
 

  • 0
Posted

Para alterar a moeda usada de Moedas de Ouro para Zeny, basta trocar a linha em que a variável .coin é definida:

set .coin, 671;

Por:

set .coin, 1;

Assim, a moeda usada será 1 Zeny.

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

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