#CASHPOINTS and #KAFRAPOINTS

alohadoubt

New member
Messages
16
Points
0
are this commands #CASHPOINTS and #KAFRAPOINTS can be use in NPC script? can someone give me a sample.

 
Code:
if( #CASHPOINTS < 999 ) {mes "Not enough cash points";close;}#CASHPOINTS = #CASHPOINTS - 999;close;
 
    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?

 
Last edited by a moderator:
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.

 
Last edited by a moderator:
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

 
Last edited by a moderator:
You can do like this too,

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