Jump to content
  • 0

Loja em Sistema de Fidelidade


JulioFortunato

Question


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  20
  • Reputation:   0
  • Joined:  12/21/12
  • Last Seen:  

Boa tarde, pessoal

 

Estou usando este sistema de fidelidade em meu servidor:

/*
	        __           __           
	 /     /  )_/    '  (  _ _ ' _/ _ 
	(__.  (__/ /()/)/  __)( / //)/_)  
							  /       
	
	Cronus, bRA & rA.
	Description: Sistema de Fidelidade
	Author: Leandro Otoni
	Pedido: Biju, Ryuho e mais. '-'
	Version: 1.0
	
	Changelog:	
	1.0 Criação do NPC [L.Otoni]

*/
//=========================================
//	SQL
//	-	Copiar e colar no PhpMyAdmin
/*=========================================

	ALTER TABLE `login` 
	ADD `loyalty_minute` INT NOT NULL DEFAULT '0' , 
	ADD `loyalty_points` INT NOT NULL DEFAULT '0' ;

*/

// Quando player logar começa a contagem de tempo online.
// A cada hora ele ganha 1 ponto
// Premiações extras a cada meta completa
// A contagem é salva por conta
-	script	loyalty#controller	-1,{ OnInit:
//====================================================
//	Configurações Sistema Fidelidade
//====================================================
//----------------------------------------------------
//	1.	Quantidade de pontos de fidelidade por hora
	set .pontos, 1;			// Padrão: 1 ponto por hora
//----------------------------------------------------
//	2.	Permitir contagem de pontos em @at/Vending?
//	-	(0) Não permitir, (1) Permitir
	set .vending, 0;		// Padrão: (0) Não permitir
//----------------------------------------------------
//	3.	Utilizar Cash ao inves de Pontos de Fidelidade?
//	-	Caso ativado atribuirá a quantidade de pontos 
//		p/hora ao comando @cash, sendo assim a cada 1h
//		online o player recebe X de cash (rops).
//	-	(0) Não permitir, (1) Permitir
	set .cash, 0;			// Padrão: (0) Desativado
//----------------------------------------------------
//	4.	Ativa sistema de conquistas?
//	-	Pontos extra para cada conquista alcançada
//	-	(0) Desativar, (1) Ativar
	set .achievement, 1;	// Padrão: (1) Ativar
//----------------------------------------------------
//	5.	Ativar Loja Itens Fidelidade
//	-	(0) Desativar, (1) Ativar
	set .shop, 1;			// Padrão: (1) Ativar
//----------------------------------------------------
//	5.1	Itens Loja Fidelidade
//	-	<item_id>,<qtd_pontos>{<item_id>,<qtd_pontos>,...};
	setarray .itens[0], 12208, 150, 14592, 150, 12103, 250;
//----------------------------------------------------
//====================================================
//	Conquistas
//====================================================
//	<n° horas>,<quantidade pontos>;
//	6,5; 6 horas = 5 pontos.
//	Deixar ( apenas no ultimo
	setarray .achievements[0],	6, 5,
								12, 20,
								24, 80,
								48, 320,
								96, 1280,
								192, 5120,
								384, 20480,
								768, 81920; // Ultimo

//====================================================
//	IMPORTANTE: Não Alterar as linhas abaixo
//====================================================									
donpcevent "loyalty#agent::OnInit"; end; // Carregando Loja
//----------------------------------------------------
//	Contagem de minutos/pontos
OnPCLoginEvent:
	while(1)
	{
		sleep2 60000; // 1 minuto
		if(!checkvending() || .vending)
		{
			query_sql("UPDATE `login` SET `loyalty_minute` = `loyalty_minute` + '1' WHERE `account_id` = '"+getcharid(3)+"'");
			query_sql("SELECT `loyalty_minute` FROM `login` WHERE account_id = '"+getcharid(3)+"'",.@minuto);
			if( !(.@minuto%60) )
			{
				if( .cash )
				{
					atcommand "@cash " + .pontos + "";
					dispbottom "Você acaba de receber "+.pontos+" ponto(s) de fidelidade";
				}
				else query_sql("UPDATE `login` SET `loyalty_points` = `loyalty_points` + '"+.pontos+"' WHERE `account_id` = '"+getcharid(3)+"'");
				
				if( .achievement )
				{
					for(set .@i, 0; .@i < getarraysize(.achievements); set .@i, .@i + 2)
						if( .achievements[.@i] == ( .@minuto / 60 ) ) {
							if( .cash )
							{
								atcommand "@cash " + .achievements[.@i+1];
								dispbottom "Você acaba de receber "+.pontos+" ponto(s) de fidelidade";
							}
							else query_sql("UPDATE `login` SET `loyalty_points` = `loyalty_points` + "+.achievements[.@i+1]+" WHERE account_id = '"+getcharid(3)+"'");
							announce "[Sistema de Fidelidade]: Conquista obtida, "+.achievements[.@i]+"h online, parabéns! Receba "+.achievements[.@i+1]+" Pontos de "+(.cash? "Cash" : "Fidelidade"),bc_self,0xBF5EFF;
						}
				}
			}
		}
	}
end;
}

-	script	loyalty#agent	-1,{ 
	query_sql ("SELECT `loyalty_minute` / 60 , `loyalty_minute`, `loyalty_points` FROM `login` WHERE account_id = '"+getcharid(3)+"'",.@hora,.@minuto, @loyalty);
	set .npc$, "^6F34C2[Sistema de Fidelidade]^000000";
	mes .npc$;
	mes "Seja bem vind"+(Sex?"o":"a")+" ^ff0000"+strcharinfo(0)+"^000000!";
	mes "Tempo de Jogo: ^ff0000"+.@hora+" hora"+(.@hora > 1? "s" : "")+" e "+(.@minuto%60)+" minuto"+(.@minuto > 1? "s" : "")+"^000000.";
	mes "Pontos de Fidelidade: ^6F34C2"+ @loyalty + "^000000";
	mes "^F7AD00- Você pode acumular Pontos de Fidelidade permanecendo on-line.^000000";
	mes "^3487C2- Você pode resgartar diversos prêmios com Pontos de Fidelidade.^000000";
	next;
	switch(select("Sair"+( getvariableofnpc(.shop, "loyalty#controller") ? ":Resgatar Itens" : ":" )+( getvariableofnpc(.achievement, "loyalty#controller") ? ":Premiações Extras" : "" )))
	{
		case 1: { mes .npc$; mes "Tudo bem, tenha um bom dia."; close; }
		case 2: { mes .npc$; mes "É pra já, olha só os itens incríveis que temos em nossa lojinha. ^^"; close2; /*openshop("loyalty#shop");*/ goto OnShop; end; }
		case 3:
			mes .npc$;
			mes "Premiação Padrão";
			mes "^ff0000Por Hora:^000000 1 Ponto de Fidelidade.";
			mes " ";
			mes "Premiações Extras: " + ( .@hora < getelementofarray(getvariableofnpc(.achievements, "loyalty#controller"), (getarraysize(getvariableofnpc(.achievements,"loyalty#controller")) - 2 )) ? "^ff0000Incompleto!":"^00B0EFCompleto!") + "^000000";
			
			for(set .@i, 0; .@i < getarraysize(.achievement); set .@i, .@i + 2)
			{
				mes ( .@hora < .achievement[.@i] ? "^ff0000" + .achievement[.@i] + "h^000000: " : "^999999" + .achievement[.@i] + ": ")  + .achievement[.@i+1] + " Pontos de "+(getvariableofnpc(.cash,"loyalty#controller")? "Cash" : "Fidelidade")+".";
			}
			next;
			mes .npc$;
			mes "Continue juntando Pontos de Fidelidade e troque por itens incríveis aqui comigo. ^^";
			mes "Tenha um bom jogo e nos vemos por aí!";
			close;
	}
	
OnShop:
	callshop "loyalty#shop1",1;
	npcshopattach "loyalty#shop1";
end;
OnBuyItem:
 
for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) {
for(set .@d,0; .@d<getarraysize(@bought_nameid); set .@d,.@d+1) {
if(@bought_nameid[.@d]==.itens[.@i]) {
set  @price, .itens[.@i+1];
if(@loyalty < @price*@bought_quantity[.@d]) 
{
mes .npc$;
mes "^F05754Me desculpe, mas você não tem pontos de Fidelidade o sufuciente!^000000";
mes " ";
mes "Pontos de Fidelidade: ^6F34C2"+ @loyalty + "^000000";
mes "Preço do Item: ^ff0000"+ @price*@bought_quantity[.@d]+"^000000";
mes "^ff0000A sua compra foi cancelada!^000000";
close;
end;
}
 
query_sql("UPDATE `login` SET `loyalty_points` = `loyalty_points` - '"+@price*@bought_quantity[.@d]+"' WHERE `account_id` = '"+getcharid(3)+"'");
dispbottom "Você gastou "+@price*@bought_quantity[.@d]+" ponto(s) de fidelidade e agora possui "+(@loyalty - @price*@bought_quantity[.@d])+" ponto(s)";
getitem @bought_nameid[.@d],@bought_quantity[.@d]; end;
}
}
}

// Carregando Confs
OnInit:
	npcshopdelitem "loyalty#shop1",501; // Removendo o item necessario para a criação da loja
	copyarray .achievement[0], getvariableofnpc(.achievements[0],"loyalty#controller"),getarraysize(getvariableofnpc(.achievements,"loyalty#controller"));
	copyarray .itens[0], getvariableofnpc(.itens[0],"loyalty#controller"),getarraysize(getvariableofnpc(.itens,"loyalty#controller"));
	
	// Adcionando os itens a loja
	for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) 
		npcshopadditem "loyalty#shop1", .itens[.@i],.itens[.@i+1];
end;
}
//=================================================================
//	IMPORTANTE: Não apagar/alterar essa linha
//=================================================================
-	shop	loyalty#shop1	-1,501:50
//-----------------------------------------------------------------

/*
	Duplicates
*/
prontera,143,178,5	duplicate(loyalty#agent)	Sapo da Fidelidade#prt	614

/* Fim do NPC */

 

Porém, ao selecionar a opção de Resgatar Prêmios, a loja de itens se abre vazia, em branco.

Os itens configurados no array no início do arquivo não são carregados na loja.

 

Alguém pode me ajudar, por favor?

Obrigado! ^^

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  350
  • Reputation:   43
  • Joined:  09/07/12
  • Last Seen:  

você define a matriz como  items

//----------------------------------------------------
// 5.1 Items Shop Loyalty
// - <Item_ID>, <qtd_pontos> {<item_id>, <qtd_pontos>, ...};
setarray. items [0],  12208,  150,  14592,  150,  12103,  250;
//----------------------------------------------------

 

 

 
 
mas você estiver usando  itens
 

copyarray. items [0], getvariableofnpc, getarraysize (getvariableofnpc (items, "loyalty # controller").) (items [0], "loyalty # controller".);
 
// Adcionando the items the store
for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) 
npcshopadditem "loyalty #  shop1",. items [.i ,.] items [.i + 1];
 
end;

 

 

 
e
 
Citar
 

OnBuyItem :
 
for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) {

 

 

verificar também se há outras coisas

 




ENGLISH TRANSLATION:
 

you set the array as items

 

//----------------------------------------------------

// 5.1 Items Shop Loyalty
// - <Item_id>, <qtd_pontos> {<item_id>, <qtd_pontos>, ...};
setarray. items [0],  12208,  150,  14592,  150,  12103,  250;
//----------------------------------------------------

 

 

but you are using itens
 

 

copyarray . itens [ 0 ], getvariableofnpc (. itens [ 0 ], "loyalty#controller" ), getarraysize ( getvariableofnpc (. itens , "loyalty#controller" ));
 
// Adcionando the items the store
for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) 
npcshopadditem "loyalty #  shop1",. items [.i ,.] items [.i + 1];

 

end;

and

 

 

OnBuyItem :

 
for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) {

 

 

also check for other things




I hate translating..

Edited by benching
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  20
  • Reputation:   0
  • Joined:  12/21/12
  • Last Seen:  

você define a matriz como  items

 

//----------------------------------------------------

// 5.1 Items Shop Loyalty

// - <Item_ID>, <qtd_pontos> {<item_id>, <qtd_pontos>, ...};

setarray. items [0],  12208,  150,  14592,  150,  12103,  250;

//----------------------------------------------------

 

 

 

mas você estiver usando  itens

 

copyarray. items [0], getvariableofnpc, getarraysize (getvariableofnpc (items, "loyalty # controller").) (items [0], "loyalty # controller".);

 

// Adcionando the items the store

for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) 

npcshopadditem "loyalty #  shop1",. items [.i ,.] items [.i + 1];

 

end;

 

 

e

 

Citar

 

OnBuyItem :

 

for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) {

 

verificar também se há outras coisas

 

ENGLISH TRANSLATION:

 

you set the array as items

//----------------------------------------------------

// 5.1 Items Shop Loyalty

// - <Item_id>, <qtd_pontos> {<item_id>, <qtd_pontos>, ...};

setarray. items [0],  12208,  150,  14592,  150,  12103,  250;

//----------------------------------------------------

 

 

but you are using itens

 

copyarray . itens [ 0 ], getvariableofnpc (. itens [ 0 ], "loyalty#controller" ), getarraysize ( getvariableofnpc (. itens , "loyalty#controller" ));

 

// Adcionando the items the store

for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) 

npcshopadditem "loyalty #  shop1",. items [.i ,.] items [.i + 1];

 

end;

and

 

OnBuyItem :

 

for(set .@i, 0; .@i < getarraysize(.itens); set .@i, .@i + 2) {

 

 

also check for other things

I hate translating..

 

No, there isn't this difference between "items" and "itens" on my script.

 

Maybe this happened to you because of the translation :(

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  350
  • Reputation:   43
  • Joined:  09/07/12
  • Last Seen:  

Tentou fazê-lo no meu lado,
e esta parte não está funcionando corretamente.

copyarray .itens[0], getvariableofnpc(.itens[0],"loyalty#controller"),getarraysize(getvariableofnpc(.itens,"loyalty#controller"));

 

e eu não sei porquê, parece que ele não pode acessar os .itens variáveis ​​[] de lealdade # controlador.
 
 
se o controlador de loyalty#controller vai usar as .itens[], seria melhor se você acabou de inicializar os .itens[] no loyalty#agent

btw, OnInit are automatically called, no need to call it,

 

remove this, leave the end;

 

 

  1. donpcevent "loyalty#agent::OnInit"; end; // Carregando Loja
Edited by benching
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  06/06/13
  • Last Seen:  

Link to comment
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.   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.

×
×
  • Create New...