Jump to content
  • 0
alohadoubt

#CASHPOINTS and #KAFRAPOINTS

Question

6 answers to this question

Recommended Posts

  • 0

 

    input @ticket;

         if(countitem(30801)<@ticket)  {

           cutin "kafra_06.bmp",255;

           mes .@adikrepname$;

           mes "Insufficient A.D. tickets. Please come back when you have enough tickets.";

           close;

         }

         delitem 30801,@ticket;

         set #CASHPOINTS, #CASHPOINTS+(@adtpoints*@ticket);

         cutin "kafra_06.bmp",255;

         mes .@adikrepname$;

         mes "Cash Points Added.";

         close;

let say if the user input -1 or just 0 or letter

how do I add additional check on user input?

Edited by alohadoubt

Share this post


Link to post
Share on other sites
  • 0

You can cap a variable under certain limits. Check input script command at https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L1560

*input(<variable>{,<min>{,<max>}})

 

Or, if you don't trust the auto capping, you can reiterate it until you get a number you want from the user by using a do...while:

do {	mes "Please, insert a number between 0 and 100!!";	input .@number;} while (.@number < 0 || .@number > 100);

 

Hope this helps.

 

P.S.: I don't know what happens if you expect a number but enter a string or a single character, but I think it gets converted to the decimal ASCII value of the number or so.

Share this post


Link to post
Share on other sites
  • 0

perfect this seems to work

 

 

    do  {
         input @ticket;
       } while (@ticket < 1 || @ticket > 1000);

         if(countitem(30801)<@ticket)  {
           cutin "kafra_06.bmp",255;
           mes .@adikrepname$;
           mes "Insufficient A.D. tickets. Please come back when you have enough tickets.";
           close;
         }
         delitem 30801,@ticket;
         set #CASHPOINTS, #CASHPOINTS+(@adtpoints*@ticket);
         cutin "kafra_06.bmp",255;
         mes .@adikrepname$;
         mes "Cash Points Added.";
         close;

 

thanks

Edited by alohadoubt

Share this post


Link to post
Share on other sites
  • 0

You can do like this too,

do {   next;   mes "Insert The Amount";} while (input(@ticket,1,100)!=0);

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

×
×
  • Create New...

Important Information

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