Jump to content
  • 0

Question

Posted

Good night. I would like to know where I set the variable for the first time for my npc give the item only 10 times.

I made it this far .. but now I was lost.
 

prontera,152,167,4    script    [Tickets VIP]    63,{

if(#ticket >= 10) {
                mes "^ FF0000 Enjoy our free VIP week! ^ 000000";
                close;
            }

mes "^ FF0000Welcome to the HonorBR ^ 000000 Server";
    mes "===========================";
    mes "I'll give you one";
    mes "^0000FF Ticket de VIP^000000 (id: 35250).";    
    getitem 35250,1;    
    set #ticket, #ticket +1;
next;
    mes "We hope you enjoy our";
    mes "free VIP week. Any questions are just";
    mes "ask there in our Discord!";
    close;
}

Sorry for the simplicity of my npc .. I'm still learning.

Thank you for your attention.
 

4 answers to this question

Recommended Posts

  • 1
Posted (edited)

you don't need to define the variable before you use it, any new variable you use by default is int 0 string ""

so you can right away

if(#var < 11){

//your code

#var++;

}

Edited by sader1992
  • Upvote 1
  • 0
Posted
1 hour ago, sader1992 said:

what you need is a global variable "$var"

this variable is for the server and will be saved in sql

i suggest you read more about rAthena's variables here

https://github.com/rathena/rathena/blob/4ba54838fe78d86fd5e03ebe5ffcd650e092cac9/doc/script_commands.txt#L428

 

Sader. thanks for the tip. I think you did not understand. My question is about programming logic.
I start with an if.

if #ticket> = 10 speech is over.

then I continue the if:
getitem
Sect is variable by +1.
my question is where to set the variable to 0 for the first time and prevent looping from set to 0 and +1.

  • 0
Posted
22 minutes ago, sader1992 said:

you don't need to define the variable before you use it, any new variable you use by default is int 0 string ""

so you can right away

if(#var < 11){

//your code

#var++;

}

Thank for help.

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