[devRev4] Return scrolls have level requirements

Welcome in the osRose emulator Project.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

[devRev4] Return scrolls have level requirements

Postby kismetbecomes on Wed Apr 10, 2013 10:32 am

Good day Osrose.
It has been very silent for the past months now. :|

Anyway, I had this idea of requiring minimum levels to use return scrolls. I'm having problems how to code it inside extrafunctions.cpp. And before anything else I would like to remind you I' am not a programmer - not in atleast a few more months and a dozen more trial and errors inside the rev codes. :D

  1.  
  2.  
  3.  
  4. if( (useitem->itemnum>347 && useitem->itemnum<371) ){
  5.  //I'm using 348-370 slots for both new and old scroll in the list_useitem.stb.. this code should work right?
  6.                
  7.         //Adventurer Plains Return Scroll
  8.                 if( thisclient->Stats->Level < 1 )  //this will check the level of the player before the warp code kicks in?
  9.                 {
  10.                    SendPM(thisclient,"You do not meet the required level to use this item.");
  11.                     return NULL;
  12.                 }
  13.                 useitem->usescript = 2;
  14.                 switch( useitem->itemnum )
  15.                 {
  16.                     case 350:
  17.                         useitem->usetype = 22;
  18.                         useitem->usevalue = 56545213;
  19.                     break;
  20.                 }
  21.  
  22.       //Zant Return Scroll
  23.                 if( thisclient->Stats->Level < 20  )
  24.                 {
  25.                    SendPM(thisclient,"You do not meet the required level to use this item.");
  26.                     return NULL;
  27.                 }
  28.                 useitem->usescript = 2;
  29.                 switch( useitem->itemnum )
  30.                 {
  31.                     case 351:
  32.                     useitem->usetype = 1;
  33.                     useitem->usevalue = 52405192;
  34.                     break;
  35.                 }
  36.  
  37.  
  38.        //Junon Return Scroll
  39.                 if( thisclient->Stats->Level < 30  )
  40.                 {
  41.                    SendPM(thisclient,"You do not meet the required level to use this item.");
  42.                     return NULL;
  43.                 }
  44.                 useitem->usescript = 2;
  45.                 switch( useitem->itemnum )
  46.                 {
  47.                     case 352:
  48.                     useitem->usetype = 2;
  49.                     useitem->usevalue = 56545228;
  50.                     break;
  51.                 }
  52.                
  53.  }
  54.  
  55.  
  56.  


Well, this code bugs. The level requirement do not work properly, like, I still cannot use a zant scroll even if I'am level 20 or more. Please tell me what is wrong with my code. :) Thanks
Last edited by kismetbecomes on Wed Apr 10, 2013 3:34 pm, edited 1 time in total.
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] Return scrolls have level requirements

Postby PurpleYouko on Wed Apr 10, 2013 2:20 pm

Your switch code is all messed up.
You should have one switch command then all the cases should be listed inside it.
Your conditions need to be inside the cases.
Your conditions are not only outside of the cases but outside of your switches

here's an example of how it should look
  1.  
  2. else //Return Scrolls
  3.             if( (useitem->itemnum>349 && useitem->itemnum<355) ||
  4.                 (useitem->itemnum>359 && useitem->itemnum<368) ||
  5.                 (useitem->itemnum==945 )  ||
  6.                 (useitem->itemnum>1029 && useitem->itemnum<1035) )
  7.             {
  8.                 if( thisclient->Stats->MP < 33 )
  9.                 {
  10.                     delete useitem;
  11.                     return NULL;
  12.                 }
  13.                 thisclient->Stats->MP -= 32;
  14.                 useitem->usescript = 2;
  15.                 switch( useitem->itemnum )
  16.                 {
  17.                     //Adventure's Plains - Drop only - [credits to tomiz]
  18.                     case 350:
  19.                         //your level check goes here
  20.                        if( thisclient->Stats->Level < 1 )  //this will check the level of the player before the warp code kicks in?
  21.                         {
  22.                               SendPM(thisclient,"You do not meet the required level to use this item.");
  23.                               return NULL;
  24.                         }
  25.                         useitem->usetype = 22;
  26.                         useitem->usevalue = 58005200; //Original AP
  27.                         // useitem->usevalue = 51105310; // new AP
  28.                     break;
  29.                     //Zant
  30.                     case 351:
  31.                         // level check for Zant goes here
  32.                        if( thisclient->Stats->Level < 20  )
  33.                        {
  34.                            SendPM(thisclient,"You do not meet the required level to use this item.");
  35.                            return NULL;
  36.                        }
  37.                         useitem->usetype = 1;
  38.                         useitem->usevalue = 52405192;
  39.                     break;
  40.                     //Junon Polis
  41.                     case 352:
  42.                         useitem->usetype = 2;
  43.                         useitem->usevalue = 55095283;
  44.                     break;
  45.                     //Eucar
  46.                     case 353:
  47.                         useitem->usetype = 51;
  48.                         useitem->usevalue = 53665099;
  49.                     break;


On another note level 20 is a bit high for using a Zant scroll. Zant is a level 10 zone
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: [devRev4] Return scrolls have level requirements

Postby kismetbecomes on Wed Apr 10, 2013 2:35 pm

Thanks again PY!

I thought I cannot call a condition inside switch. :D

I guess I was just getting the hang of this. :D
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] Return scrolls have level requirements

Postby PurpleYouko on Thu Apr 11, 2013 1:51 pm

You can do most anything inside a switch.
About the only thing it will complain about is if you attempt to initialize a variable inside one but even that can be worked around by putting braces around the code inside the case.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: [devRev4] Return scrolls have level requirements

Postby kismetbecomes on Thu Apr 11, 2013 3:56 pm

Thanks a lot again PY.
Your code worked terrific. :D

Nice to know there are still people around here.
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] Return scrolls have level requirements

Postby Circa on Fri Apr 12, 2013 3:41 am

PurpleYouko wrote:You can do most anything inside a switch.
About the only thing it will complain about is if you attempt to initialize a variable inside one but even that can be worked around by putting braces around the code inside the case.


Idk about you guys but I always put braces in each case lol except if they're one line. They are technically"if statements". I kinda cringe when I don't see braces i cases that have a bunch of lines
Circa
Clown
Clown
 
Posts: 404
Joined: Sun Aug 23, 2009 5:52 am
Location: CA

Re: [devRev4] Return scrolls have level requirements

Postby kismetbecomes on Fri Apr 12, 2013 4:23 am

Circa wrote:
PurpleYouko wrote:You can do most anything inside a switch.
About the only thing it will complain about is if you attempt to initialize a variable inside one but even that can be worked around by putting braces around the code inside the case.


Idk about you guys but I always put braces in each case lol except if they're one line. They are technically"if statements". I kinda cringe when I don't see braces i cases that have a bunch of lines


That is for YOU guys, because you are programmers and I should stress VERY good at it. :lol:

But anyway, I'm learning bunch of things just by going over and asking. It's a great help when you help out. So, I salute y'all for that.
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] Return scrolls have level requirements

Postby PurpleYouko on Fri Apr 12, 2013 1:54 pm

Circa wrote:
PurpleYouko wrote:You can do most anything inside a switch.
About the only thing it will complain about is if you attempt to initialize a variable inside one but even that can be worked around by putting braces around the code inside the case.


Idk about you guys but I always put braces in each case lol except if they're one line. They are technically"if statements". I kinda cringe when I don't see braces i cases that have a bunch of lines

Yeah I tend to as well.
technically it will work for most things by just running to the break command but not having braces causes too many exceptions in my experience.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm


Return to Support - OsRose Emulator

Who is online

Users browsing this forum: No registered users and 15 guests