Advertisement
Vlync

Untitled

May 21st, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 13.89 KB | None | 0 0
  1. // (--------------------------------------------------------------------) \\
  2. // (                                                                    ) \\
  3. // (         ___________                           __  .__              ) \\
  4. // (         \_   _____/____    ___________  _____/  |_|  |__           ) \\
  5. // (          |    __) \__  \ _/ __ \_  __ \/  _ \   __\  |  \          ) \\
  6. // (          |     \   / __ \\  ___/|  | \(  <_> )  | |   Y  \         ) \\
  7. // (          \___  /  (____  /\___  >__|   \____/|__| |___|  /         ) \\
  8. // (              \/        \/     \/                       \/          ) \\
  9. // (                                                                    ) \\
  10. // ( ---------------------------- SQL Only ---------------------------- ) \\
  11. // (                                                                    ) \\
  12. // ( ---------------------------- Beta 1.4 ---------------------------- ) \\
  13. // (                                                                    ) \\
  14. // ( ~ 11/08/07: Basic system.                                          ) \\
  15. // ( ~ 12/08/07: Update System, fixed some duplicate-bug with this.     ) \\
  16. // ( ~ 16/08/07: Callshop gefixt; Abbrechnung berarbeitet.              ) \\
  17. // ( ~ 20/08/07: Alpha Version is working an finished.                  ) \\
  18. // ( ~ 21/08/07: Function fixed to delete items.                        ) \\
  19. // ( ~ 17/10/07: First huge revision of the script.                     ) \\
  20. // ( ~ 20/12/07: New Layout; Bug Fixes.                                 ) \\
  21. // ( ~ 27/12/07: Fixed the dynamic menu.                                ) \\
  22. // ( ~ 21/01/08: Optimation to make the script working for every SVN.   ) \\
  23. // (                                                                    ) \\
  24. // ( --------------------------- Instruction: ------------------------- ) \\
  25. // (                                                                    ) \\
  26. // ( 1) Import 'installation.sql' into the SQL-DBs.                     ) \\
  27. // ( 2) Chose the GM Level for the Admin Menu.                          ) \\
  28. // ( 3) Map, coordinates and name.                                      ) \\
  29. // ( 4) Load the NPC.                                                   ) \\
  30. // ( 5) Reload the NPCs again.                                          ) \\
  31. // ( 6) Lock the NPC.                                                   ) \\
  32. // ( 7) Add items with prices.                                          ) \\
  33. // ( 8) Chose the way to pay.                                           ) \\
  34. // ( 9) First help: Chose "- Debug Help." in the Admin Menu.            ) \\
  35. // (                                                                    ) \\
  36. // ( ---------------------------- Config: ----------------------------- ) \\
  37.  
  38. -   script  dynamic_shop_confg  -,{
  39.  
  40. OnInit:
  41.  
  42.     set $ds_conf[0], 99; // Instruction 2)
  43.  
  44.     end;
  45.  
  46. }
  47.  
  48. // ( ------------------------------------------------------------------ ) \\
  49.                                                          
  50. prontera,147,173,5, script  Faeroth::Dynamic_Shop   762,{
  51.  
  52. set @n$,"~ ^00B200Faeroth^000000 ~";
  53.  
  54.     function AMS;
  55.     function DEBUG_MES;
  56.     function RESET;
  57.  
  58.     if(getgmlevel() < $ds_conf[0]){
  59.  
  60.         if($dynamic_shop_sperre){
  61.  
  62.             mes @n$;
  63.             mes "I'm sorry, the NPC has been locked by an Admin.";
  64.             close;
  65.            
  66.         } else if($ds_conf[2]){
  67.  
  68.             mes @n$;
  69.             mes "Hello, I only want to advise you of the fact that you have to pay with the item ^999999" + getitemname($ds_conf[2]) + " instead of Zenys.^000000";
  70.             mes "^FF0000(So the amount of Zenys stands for the amount of items.)";
  71.             close2;
  72.            
  73.         }
  74.  
  75.         callshop "Dynamic_Shop",1;
  76.         npcshopattach "Dynamic_Shop";
  77.         end;
  78.  
  79.     } else {
  80.    
  81.         set @admin_menu, 0;
  82.        
  83.         while(!@admin_menu){
  84.    
  85.             mes @n$;
  86.             mes "Hello, what do you want to do?";
  87.             mes " ";
  88.             mes "~ ^FF0000Status:^000000 ~";
  89.            
  90.             if(!$ds_conf[2])
  91.                 mes "^FF9900You pay with Zenys in the shop.";
  92.             else
  93.                 mes "^FF9900You pay with the item ^999999" + getitemname($ds_conf[2]) + " (ID: " + $ds_conf[2] + ") ^FF9900in the shop!^000000";
  94.                
  95.             if($dynamic_shop_sperre)
  96.                 mes "^FF0000The NPC is locked.^000000";
  97.                
  98.             next;
  99.  
  100.             switch(select("- Add an item with price.:- List all item with their prices.:- Chose the way to pay.:- Lock/unlock the NPC.:- Debug Help.:- Preview of the shop.:- Nothing, thanks.")){
  101.  
  102.                 case 1:
  103.                     if( (AMS("add an item with price")) && (!@AMS) ) break;
  104.  
  105.                     mes @n$;
  106.                     mes "Please input the ^FF0000Item ID^000000.";
  107.                     mes "^FF0000Attention: If it's the wrong ID, it may cause errors!";
  108.                     next;
  109.                     input @item_id;
  110.                    
  111.                     mes @n$;
  112.                     mes "Please input now the ^FF0000Price^000000 for the items.";
  113.                     next;
  114.                     input @price;
  115.  
  116.                     mes @n$;
  117.                     mes "Summary:";
  118.                     mes "^FF0000Name: " + getitemname(@item_id);
  119.                     mes "ID: " + @item_id;
  120.                     mes "Price: " + @price + "^000000";
  121.                     mes "Is everything fine?";
  122.                     next;
  123.                     if(!(select("- No!:- Yes.") -1)){
  124.                    
  125.                         mes @n$;
  126.                         mes "The action has been aborted.";
  127.                         next;
  128.                         break;
  129.                        
  130.                     } else {
  131.  
  132.                         query_sql "INSERT INTO `dynamic_shop` ( `id` , `price` ) VALUES ( '"+@item_id+"' , '"+@price+"' )";
  133.                        
  134.                         npcshopadditem "Dynamic_Shop", @item_id, @price;
  135.  
  136.                         mes @n$;
  137.                         mes "The new item has been added!";
  138.                         next;
  139.                         break;
  140.  
  141.                     }
  142.  
  143.                 case 2:
  144.                     set @admin_menu,1;
  145.                    
  146.                         while(@admin_menu){
  147.                        
  148.                             RESET(1);
  149.  
  150.                             query_sql "SELECT * FROM `dynamic_shop`", @id_all, @price_all;
  151.  
  152.                             if(!@id_all[0]){
  153.                            
  154.                                 set @admin_menu,0;
  155.  
  156.                                 mes @n$;
  157.                                 mes "You don't have added any ^FF0000Items^000000 yet..";
  158.                                 next;
  159.                                
  160.                             } else {
  161.  
  162.                                 mes @n$;
  163.                                 mes "All of the ^FF0000Items^000000 will now be listed as a Menu.";
  164.                                 mes "If you want to delete one, you may chose it.";
  165.                                 mes "^FF0000Attention:^000000 Name ( ID , Price ).";
  166.                                 next;
  167.                                
  168.                                 set .@menu_d$, "- " + getitemname(@id_all[0]) + " ( " + @id_all[0] + " , " + @price_all[0] + " )";
  169.  
  170.                                 for( set @i, 1; @i < getarraysize(@id_all); set @i, @i + 1)
  171.                                     set .@menu_d$, .@menu_d$ +  ":- " + getitemname(@id_all[@i]) + " ( " + @id_all[@i] + " , " + @price_all[@i] + " )";
  172.  
  173.                                 set .@menu_d$, .@menu_d$ + ":- I'm finished, thanks.";
  174.  
  175.                                 set @m, select (.@menu_d$) - 1;
  176.  
  177.                                 if(@m == getarraysize(@id_all)){
  178.                                
  179.                                     set @admin_menu, 0;
  180.                                     break;
  181.                                    
  182.                                 }
  183.  
  184.                                 mes @n$;
  185.                                 mes "Do you want to delete the ^FF0000Item^000000 ^FF0000" + getitemname(@id_all[@m]) + "^000000 with the ID ^FF0000" + @id_all[@m] + "^000000?";
  186.                                 next;
  187.                                 if(select("- No.:- Yes!") -1){
  188.  
  189.                                     query_sql "DELETE FROM `dynamic_shop` WHERE `id` = '"+@id_all[@m]+"'";
  190.                                    
  191.                                     npcshopdelitem "Dynamic_Shop", @id_all[@m];
  192.  
  193.                                     mes @n$;
  194.                                     mes "The item has been deleted.";
  195.                                     next;
  196.                    
  197.                                 }
  198.                            
  199.                             }
  200.                        
  201.                         }
  202.  
  203.                     break;
  204.  
  205.                 case 3:
  206.                     if( (AMS("chose the way to pay")) && (!@AMS) ) break;
  207.  
  208.                     set @backup, $ds_conf[2];
  209.  
  210.                     mes @n$;
  211.                     mes "Please input the ^999999ID^000000 of an ^FF0000Item^000000 to be payed with.";
  212.                     mes "^FF0000Attention: Insert 0 means pay with Zenys.";
  213.                     next;
  214.                     input $ds_conf[2];
  215.                    
  216.                     if(!$ds_conf[2]){
  217.  
  218.                         mes @n$;
  219.                         mes "Should you pay with ^999999Zenys^000000 in the shop?";
  220.                         next;
  221.                         if(!(select("- Nein!:- Ja.") -1)){
  222.                        
  223.                             mes @n$;
  224.                             mes "Aborted.";
  225.                             next;
  226.                             set $ds_conf[2], @backup;
  227.                             break;
  228.                            
  229.                         } else {
  230.                        
  231.                             mes @n$;
  232.                             mes "You will pay with ^999999Zenys^000000 nowt.";
  233.                             next;
  234.                             break;
  235.                    
  236.                         }
  237.  
  238.                     } else {
  239.  
  240.                         mes @n$;
  241.                         mes "^FF0000Name : " + getitemname($ds_conf[2]) + "^000000";
  242.                         mes "^999999Item ID: " + $ds_conf[2];
  243.                         mes "^000000Everything right?";
  244.                         next;
  245.                         if(!(select("- No, it's not.:- Yes.") -1)){
  246.  
  247.                             set $ds_conf[2], @backup;
  248.            
  249.                             mes @n$;
  250.                             mes "Aborted..";
  251.                            
  252.                             if(!$ds_conf[2])
  253.                                 mes "You will continue on paying with ^999999Zenys^000000.";
  254.                             else
  255.                                 mes "You will continue on paying with the ^FF0000Item^000000 " + getitemname($ds_conf[2]) + " gezahlt.";
  256.  
  257.                             next;
  258.                             break;
  259.  
  260.                         }
  261.  
  262.                         mes @n$;
  263.                         mes "Thank you.";
  264.                         mes "You will now have to pay with the ^FF0000Item^000000 " + getitemname($ds_conf[2]) + ".";
  265.                         next;
  266.                         break;
  267.  
  268.                     }
  269.  
  270.  
  271.                 case 4:
  272.                     mes @n$;
  273.                
  274.                     if($ue_sperre)
  275.                         mes "Do you want to ^FF0000unlock^000000 the NPC?";
  276.                     else
  277.                         mes "Do you want to^FF0000lock^000000 the NPC?";
  278.  
  279.                     next;
  280.                     if(!(select("- No.:- Yes.") -1)) break;
  281.  
  282.                     mes @n$;
  283.  
  284.                     if($ue_sperre){
  285.  
  286.                         set $ue_sperre,0;
  287.                         mes "The NPC is now ^FF0000no longer locked^000000.";
  288.                        
  289.                     } else {
  290.                    
  291.                         set $ue_sperre,1;
  292.                         mes "The NPC has been ^FF0000locked^000000.";
  293.  
  294.                     }
  295.        
  296.                     next;
  297.                     break;
  298.  
  299.  
  300.                 case 5:
  301.                     mes @n$;
  302.                     mes "If you find any bugs usw, please inform ^33CC00Faeroth | Kaze^000000.";
  303.                     mes "Contact me:";
  304.                     mes "MSN: faeroth@hotmail.de";
  305.                     mes "ICQ: 284-209-043";
  306.                     mes "eAthena: F!re";
  307.                     next;
  308.                     mes @n$;
  309.                     mes "First help:";
  310.                     mes "- Are the Item-IDs all right?";
  311.                     mes "- [...] (will follow)";
  312.                     next;
  313.                     mes @n$;
  314.                     mes "Scripted and Copyright by ^33CC00Faeroth | Kaze^000000.";
  315.                     next;
  316.                     break;
  317.                
  318.                 case 6:
  319.                     if( (AMS("see the preview of the shop")) && (!@AMS) ) break;
  320.  
  321.                     mes @n$;
  322.                     mes "The shop will be open now...";
  323.                     close2;
  324.                    
  325.                     if($ds_conf[2]){
  326.  
  327.                         mes @n$;
  328.                         mes "Hello, I only want to advise you of the fact that you have to pay with the item ^999999" + getitemname($ds_conf[2]) + " instead of Zenys.^000000";
  329.                         mes "^FF0000(So the amount of Zenys stands for the amount of items.)";
  330.                         close2;
  331.  
  332.                     }
  333.  
  334.                     callshop "Dynamic_Shop",1;
  335.                     npcshopattach "Dynamic_Shop";
  336.                     end;
  337.  
  338.                 case 7:
  339.                     mes @n$;
  340.                     mes "I'm always to your command.";
  341.                     set @admin_menu, 1;
  342.                     break;
  343.             }
  344.            
  345.         }
  346.        
  347.         close;
  348.  
  349.     }
  350.    
  351. OnBuyItem:
  352.  
  353.     set @price, 0;
  354.     set @quantity, 0;
  355.  
  356.     RESET(1);
  357.  
  358.     query_sql "SELECT * FROM `dynamic_shop`", @id_all, @price_all;
  359.    
  360.     if(!@id_all[0]) DEBUG_MES(0);
  361.  
  362.     if(!$ds_conf[2]){
  363.  
  364.         for( set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1)
  365.             for( set @z, 0; @z < getarraysize(@id_all); set @z, @z + 1)
  366.                 if(@id_all[@z] == @bought_nameid[@i])
  367.                     set @price, @price + (@price_all[@z] * @bought_quantity[@i]);
  368.  
  369.         if(Zeny < @price){
  370.  
  371.             RESET(0);
  372.  
  373.             mes @n$;
  374.             mes "You don't have enough Zenys..";
  375.             close;
  376.  
  377.         } else {
  378.  
  379.             set Zeny, Zeny - @price;
  380.  
  381.             for( set @i,0; @i < getarraysize(@bought_nameid); set @i, @i + 1)
  382.                 getitem @bought_nameid[@i], @bought_quantity[@i];
  383.  
  384.             RESET(0);
  385.             end;
  386.        
  387.         }
  388.  
  389.     } else {
  390.  
  391.         for( set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1)
  392.             for( set @z, 0; @z < getarraysize(@id_all); set @z, @z + 1)
  393.                 if(@id_all[@z] == @bought_nameid[@i])
  394.                     set @quantity, @quantity + (@price_all[@z] * @bought_quantity[@i]);
  395.  
  396.         mes "~ ^999999Bill^000000 ~";
  397.        
  398.         for( set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1 )
  399.             mes "^FF0000" + getitemname(@bought_nameid[@i]) + ": " + @bought_quantity[@i] + "^000000";
  400.  
  401.         mes "This will cost you ^999999" + @quantity + " " + getitemname($ds_conf[2]) + "^000000!";
  402.         mes "Do you want to complete the purchase?";
  403.         next;
  404.         if(!(select("- No, I don't..:- Yes, I do.") -1)){ RESET(0); mes @n$; mes "The purchase has been aborted."; close; }
  405.  
  406.         if(countitem($ds_conf[2]) < @quantity){
  407.  
  408.             RESET(0);
  409.  
  410.             mes @n$;
  411.             mes "I'm sorry, you don't have enough ^999999" + getitemname($ds_conf[2]) + "^000000...";
  412.             close;
  413.  
  414.         } else {
  415.  
  416.             delitem $ds_conf[2], @quantity;
  417.  
  418.             for( set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1 )
  419.                 getitem @bought_nameid[@i], @bought_quantity[@i];
  420.                
  421.             RESET(0);
  422.                
  423.             mes @n$;
  424.             mes "Thank you for your purchase.";
  425.             close;
  426.  
  427.         }
  428.  
  429.     }
  430.  
  431. // ( -------------------------- Functions: --------------------------- ) \\
  432.  
  433.     function AMS {
  434.  
  435.     // ( ------- Admin Menu Security-Question -------- ) \\
  436.     // ( --------- getarg(0) - Menu point ------------ ) \\
  437.  
  438.         mes @n$;
  439.         mes "Do you really want to " + getarg(0) + "?";
  440.         next;
  441.         set @AMS, select("- No.:- Yes!") - 1;
  442.        
  443.         return 1;
  444.        
  445.     }
  446.  
  447.     function DEBUG_MES {
  448.  
  449.     // ( ----- If the SQL-DBs are empty ----- ) \\
  450.     // ( ------- getarg(0) - Player --------- ) \\
  451.     // ( ------- getarg(1) - Admin ---------- ) \\
  452.  
  453.         if(!getarg(0)){
  454.  
  455.             mes @n$;
  456.             mes "^FF0000I'm sorry, it seems that there was a SQL-Error.^000000";
  457.             mes "Please try again in short.";
  458.             mes "If this isn't the first time, please inform a Gamemaster!";
  459.             close;
  460.            
  461.         } else {
  462.        
  463.             mes @n$;
  464.             mes "^FF0000There was a SQL-Error.^000000";
  465.             mes "Make sure that the tables do exist and that they are not empty!";
  466.             close;
  467.            
  468.         }
  469.        
  470.     }
  471.  
  472.     function RESET {
  473.  
  474.     // ( ---------------------- Reset of the Variables -------------------- ) \\
  475.     // ( -------- getarg(0) - 1 for SQL-RESET; 0 for OnBuyItem-RESET. ----- ) \\
  476.  
  477.         if(getarg(0)){
  478.        
  479.             deletearray @id_all, getarraysize(@id_all);
  480.             deletearray @price_all, getarraysize(@price_all);
  481.            
  482.         } else {
  483.        
  484.             deletearray @bought_quantity, getarraysize(@bought_quantity);
  485.             deletearray @bought_nameid, getarraysize(@bought_nameid);
  486.  
  487.         }
  488.        
  489.         return;
  490.  
  491.     }
  492.    
  493. // ( ------------------------------------------------------------------ ) \\
  494.  
  495. OnInit:
  496.  
  497.     npcshopdelitem "Dynamic_Shop", 512;
  498.  
  499.     query_sql "SELECT * FROM `dynamic_shop`", .id_all, .price_all;
  500.    
  501.     if(!.id_all[0])
  502.         end;
  503.    
  504.     npcshopitem "Dynamic_Shop", .id_all[0], .price_all[0];
  505.    
  506.     for( set .i, 1; .i < getarraysize(.id_all); set .i, .i + 1 )
  507.         npcshopadditem "Dynamic_Shop", .id_all[.i], .price_all[.i];
  508.  
  509.     end;
  510.    
  511. }
  512.  
  513. -   shop    Dynamic_Shop    -1,512:512 // Dummy-Shop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement