Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Class names are always upper-case as in C / C++
- Class 1 L2F_Delevel : L2FBaseNPC
- {
- parameter:
- // Parameters are always prefixed by what I'll be
- // using them for or what they hold.
- // HTML names are written: ServerName.NPCName.TitleOfPageOrFunction
- string htmlHello = "L2F.Delevel.Hello.htm";
- string htmlChooseLevel = "L2F.Delevel.ChooseLvel.htm";
- string htmlConfirmDelevel = "L2F.Delevel.Confirm.htm";
- // Ask's are listed at 1k increments.
- // Sub-Asks remain within the same 1K range but
- // incremented by 100.
- int askChooseLevel = 1000;
- int askConfirmLevel = 1100;
- // Cookies
- string cookieDesiredLevel = "L2F.Delevel.DesiredLevel";
- // errors
- string errMsgInvalidCurrentLevel = "Your current level must be greater than the one selected.";
- string errMsgInvalidConformation = "You did not correctly confirm your delevel request.";
- handler:
- EventHandler TALKED(talker)
- {
- myself.ShowPage(talker, htmlHello);
- }
- EventHandler MENU_SELECTED(talker, ask, reply, fhtml0, i0)
- {
- // We use the AdvExt compiler which does not support using switch
- // statements with class constants. Have to use a bunch of if's here.
- // I don't think it's much slower as long as you return correctly.
- if (ask == askChooseLevel)
- {
- // Reply = The level they'd like to be set to
- // selected in HTML via dropdown or input box.
- // Player should not be able to select
- // a level greater or equal to their own.
- if (talker.level < reply)
- {
- myself.FHTML_SetFileName(fhtml0, htmlGlobalErrorPage); // Defined in L2FBaseNPC superclass.
- myself.FHTML_SetStr(fhtml0, "ERROR_TITLE", "L2F > Invalid Level Selected");
- myself.FHTML_SetStr(fhtml0, "ERROR_MSG", errMsgInvalidCurrentLevel);
- myself.FHTML_SetStr(fhtml0, "ERROR_REDIRECT_PAGE", htmlHello); // Location where the "OK" button sends you.
- myself.ShowFHTML(talker, fhtml0);
- return;
- }
- myself.SetCookie(talker, cookieDesiredLevel, reply);
- myself.ShowPage(talker, htmlConfirmDelevel);
- return;
- }
- if (ask == askConfirmLevel)
- {
- // Reply = The result of whatever you asked
- // them to input in the HTML to confirm they really
- // want to be deleveled.
- // Ensure the verification checks out.
- if (reply != YOUR_VERIFICATION_OPTION)
- {
- myself.FHTML_SetFileName(fhtml0, htmlGlobalErrorPage); // Defined in L2FBaseNPC superclass.
- myself.FHTML_SetStr(fhtml0, "ERROR_TITLE", "L2F > DeLevel Verification Failed");
- myself.FHTML_SetStr(fhtml0, "ERROR_MSG", errMsgINvalidConformation);
- myself.FHTML_SetStr(fhtml0, "ERROR_REDIRECT_PAGE", htmlHello);
- myself.ShowFHTML(talker, fhtml0);
- return;
- }
- // Everything went well, Set their level using the cookie we set earlier.
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement