• 0
Sign in to follow this  
cumbe11

Fidelidade Point

Question

Hello, I use this npc that give loyalty points to use in the store, but sometimes people can buy the items even without points, I would like to know where the problem is

 

 

	-    script    Fidelidade    -1,{
	OnPCLoginEvent:
    addtimer 60000,"Fidelidade::OnTime";
    end;
	OnTime:
    if(query_sql("SELECT login.account_id FROM login LEFT JOIN `char` ON login.account_id=`char`.account_id WHERE login.last_ip=(SELECT last_ip FROM login WHERE account_id="+getcharid(3)+") AND `char`.online=1", [email protected]_id) > 2){ end; }
    if(checkvending() || #fidelidade == 30000){ end; }
    set #fidelidade,#fidelidade + 1;
    if(#fidelidadeon == 0){ dispbottom "@fidelidade : Você recebeu 1 Ponto e ficou com "+#fidelidade+" Pontos de Fidelidade, use @fidelidade."; }
    addtimer 60000,"Fidelidade::OnTime";
    end;
	OnInit:
    bindatcmd "fidelidade","Fidelidade::OnFIDELIDADE";
    setarray .ItList[0],7836,2700,6001,2700,7087,2700,12080,540,7443,540,675,360,31349,18000,31350,18000,20301,14400,18247,14400,31382,19800,31380,19800,31381,19800;
    npcshopdelitem "DynShop02",501;
    for(set .n,0;.n<getarraysize(.ItList);set .n,.n+2)
    npcshopadditem "DynShop02",.ItList[.n],.ItList[(.n+1)];
    end;
	OnBuyItem:
    for(set @n,0;@n<getarraysize(@bought_nameid);set @n,@n+1)
        for(set @a,0;@a<getarraysize(.ItList);set @a,@a+2)
            if(@bought_nameid[@n]==.ItList[@a]){
                set @PriceT,.ItList[@a+1]*@bought_quantity[@n];
                    if(#fidelidade){ if(#fidelidade<@PriceT) end; }else{ if(Zeny<@PriceT) end; }
                    getitem @bought_nameid[@n],@bought_quantity[@n];
                    if(#fidelidade) set #fidelidade,#[email protected]; else set Zeny,[email protected];
            }
    end;
	OnFIDELIDADE:
    mes "[^ff0000 "+strnpcinfo(1)+" ^000000]";
    mes "A cada minuto conectado você recebe ^0000ff1 Ponto^000000 e juntando poderá troca-los por itens em ^FF9900Trocas da Fidelidade^000000.";
    mes "^F7F7F7-^000000";
    mes "Você tem ^0000ff"+#fidelidade+" Pontos de Fidelidade^000000";
    switch(select((#fidelidadeon==1?"- Ligar Mensagens":"- Desligar Mensagens"),"- Trocas da Fidelidade")){
	        case 1:
            next;
            mes "[^ff0000 "+strnpcinfo(1)+" ^000000]";
            if(#fidelidadeon == 0){ mes "As mensagens foram desligadas."; set #fidelidadeon,1; close; } else { mes "As mensagens foram ligadas."; set #fidelidadeon,0; close; }
	        case 2:
            close2;
            callshop "DynShop02",1;
            npcshopattach "DynShop02";
            end;
	    }
	}
	
-    shop    DynShop02    -1,501:-1
	

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
Posted (edited)

Here is the problem:

Spoiler
	OnBuyItem:
    for(set @n,0;@n<getarraysize(@bought_nameid);set @n,@n+1)
        for(set @a,0;@a<getarraysize(.ItList);set @a,@a+2)
            if(@bought_nameid[@n]==.ItList[@a]){
                set @PriceT,.ItList[@a+1]*@bought_quantity[@n];
                    if(#fidelidade){ if(#fidelidade<@PriceT) end; }else{ if(Zeny<@PriceT) end; }
                    getitem @bought_nameid[@n],@bought_quantity[@n];
                    if(#fidelidade) set #fidelidade,#[email protected]; else set Zeny,[email protected];
            }
    end;

 

The script are checking if player have '#fidelidade' or 'Zeny' and if have one of them, will give the item.

So you need to change only to check '#fidelidade' points or '#fidelidade' points and 'Zeny'.

Like this:

Spoiler
		if (@bought_nameid[@n] == .ItList[@a])
		{
			set @PriceT, .ItList[@a + 1] * @bought_quantity[@n];
		
			if (#fidelidade < @PriceT)
			{
				end;
			}
			else
			{
				set #fidelidade, #fidelidade - @PriceT;

				getitem @bought_nameid[@n], @bought_quantity[@n];
			}
		}

 

 

Edited by Cretino
  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0

thank you very much.
What would you look like with only fidelidade points?

Share this post


Link to post
Share on other sites
  • 0
3 minutes ago, cumbe11 said:

thank you very much.
What would you look like with only fidelidade points?

		if (@bought_nameid[@n] == .ItList[@a])
		{
			set @PriceT, .ItList[@a + 1] * @bought_quantity[@n];
		
			if (#fidelidade < @PriceT)
			{
				end;
			}
			else
			{
				set #fidelidade, #fidelidade - @PriceT;

				getitem @bought_nameid[@n], @bought_quantity[@n];
			}
		}

 

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0

Trx... apparently it's working 100%

How could I place an ad when someone bought an item at the store?

and I wonder if this time is correct ...
Is he giving 1 point every 1 hour?

I was wondering if I could show a countdown timer to earn the point.

 

Share this post


Link to post
Share on other sites
  • 0
2 hours ago, cumbe11 said:

How could I place an ad when someone bought an item at the store?

 

and I wonder if this time is correct ...
Is he giving 1 point every 1 hour?

I was wondering if I could show a countdown timer to earn the point.

 

To put a announce is simple, you just need this script command:

announce "<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};

Just add the 'announce' after the 'getitem':

Spoiler
			else
			{
				set #fidelidade, #fidelidade - @PriceT;

				getitem @bought_nameid[@n], @bought_quantity[@n];

				announce "[" + strcharinfo(0) + "] bought [" + getitemname(@bought_nameid[@n]) + "] x" + @bought_quantity[@n] + "!!", bc_all;
			}

 

Now, about show a countdown timer...

You'll need to remake the script, changing 'addtimer' to other function.

I suggest you look at 'doc/script_commands.txt' file or look for one script with hourly reward to get a example.

Good luck.

  • Upvote 1
  • Like 1

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.   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.

Loading...
Sign in to follow this