Wyatt

SlotMachine Event NPC by ^Wyatt

Mar 5th, 2013
928
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 24.09 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_Server
  3. Index: dist/game/config/SlotMachine.properties
  4. ===================================================================
  5. --- dist/game/config/SlotMachine.properties (revision 0)
  6. +++ dist/game/config/SlotMachine.properties (revision 0)
  7. @@ -0,0 +1,20 @@
  8. +# -----------------------------------------------------------------------------------------------------------
  9. +#  L2jHidden - SlotMachine
  10. +#  Developed by Wyatt
  11. +# -----------------------------------------------------------------------------------------------------------
  12. +#  Configs
  13. +# -----------------------------------------------------------------------------------------------------------             
  14. +# Here you must especify your Server Name that will be specified in the NPC html
  15. +ServerName = L2jHidden
  16. +
  17. +# Here you must especify the ID of the NPC that you want to use
  18. +NpcId = 100
  19. +
  20. +# Here you must especify the rewards that will be given to the players
  21. +# You can add multiple rewards, Example: 57,10000000;5575,5000000
  22. +Rewards = 57,10000000;5575,5000000
  23. +
  24. +
  25. +# Here you must especify the feed that will be taken for each try
  26. +# You can add multiple feeds, Example: 57,200000;5575,50000
  27. +Feed = 57,200000;5575,50000
  28. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  29. ===================================================================
  30. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (revision 5822)
  31. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  32. @@ -496,6 +499,9 @@
  33.     private boolean _isInSiege;
  34.     private boolean _isInHideoutSiege = false;
  35.    
  36. +   //Wyatt SlotMachine Event
  37. +   public boolean win = false;
  38. +  
  39.     public enum PunishLevel
  40.     {
  41.         NONE(0, ""),
  42. ### Eclipse Workspace Patch 1.0
  43. #P L2J_DataPack
  44. Index: dist/game/data/scripts/custom/SlotMachine/SlotMachine.java
  45. ===================================================================
  46. --- dist/game/data/scripts/custom/SlotMachine/SlotMachine.java  (revision 0)
  47. +++ dist/game/data/scripts/custom/SlotMachine/SlotMachine.java  (revision 0)
  48. @@ -0,0 +1,751 @@
  49. +package custom.SlotMachine;
  50. +
  51. +import java.io.File;
  52. +import java.io.FileInputStream;
  53. +import java.util.ArrayList;
  54. +import java.util.List;
  55. +import java.util.Properties;
  56. +import javolution.text.TextBuilder;
  57. +import com.l2jserver.gameserver.datatables.ItemTable;
  58. +import com.l2jserver.gameserver.datatables.SkillTable;
  59. +import com.l2jserver.gameserver.model.actor.L2Npc;
  60. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  61. +import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
  62. +import com.l2jserver.gameserver.model.quest.Quest;
  63. +import com.l2jserver.gameserver.network.SystemMessageId;
  64. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  65. +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  66. +import com.l2jserver.util.Rnd;
  67. +import com.l2jserver.util.StringUtil;
  68. +
  69. +/**
  70. + *
  71. + * @author Wyatt
  72. + *
  73. + */
  74. +
  75. +public class SlotMachine extends Quest
  76. +{
  77. +   private static final String qn = "SlotMachine";
  78. +   private static String servername = "";
  79. +   private static List<int[]> rewards;
  80. +   private static List<int[]> feed;
  81. +   private static int npcid = 0;
  82. +
  83. +   public SlotMachine(int questId, String name, String descr)
  84. +   {
  85. +       super(questId, name, descr);
  86. +       loadConfigs();
  87. +       addStartNpc(npcid);
  88. +       addTalkId(npcid);
  89. +       addFirstTalkId(npcid); 
  90. +   }
  91. +  
  92. +   @Override
  93. +   public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  94. +   {
  95. +       if (npc.getNpcId() == npcid && event.equals("play") && checkstatus(player))
  96. +       {
  97. +           for (int[] i : feed)
  98. +           {
  99. +               if(player.getInventory().getItemByItemId(i[0]) == null || (player.getInventory().getItemByItemId(i[0]) != null && player.getInventory().getItemByItemId(i[0]).getCount() < i[1]))
  100. +               {
  101. +                   player.sendMessage("You don't have enough items.");
  102. +                   return null;
  103. +               }
  104. +           }
  105. +          
  106. +           for (int[] i : feed)
  107. +           {
  108. +               player.destroyItem("SlotMachineConsumition", player.getInventory().getItemByItemId(i[0]).getObjectId(), i[1], null, false);
  109. +           }
  110. +          
  111. +           try
  112. +           {
  113. +               for (int[] feeds : feed)
  114. +               {
  115. +                   player.sendMessage("Consumed: "+feeds[1]+" of "+ItemTable.getInstance().createDummyItem(feeds[0]).getItemName()+" by SlotMachine.");
  116. +               }  
  117. +  
  118. +               run(player);
  119. +           }
  120. +           catch (InterruptedException e)
  121. +           {
  122. +               e.printStackTrace();
  123. +           }
  124. +       }
  125. +       return null;
  126. +   }
  127. +  
  128. +   void checkresult(L2PcInstance player)
  129. +   {
  130. +       SystemMessage systemMessage = null;
  131. +      
  132. +       if(player.win)
  133. +       {
  134. +           for (int[] r : rewards)
  135. +           {
  136. +               PcInventory inv = player.getInventory();
  137. +              
  138. +               if (ItemTable.getInstance().createDummyItem(r[0]).isStackable())
  139. +               {
  140. +                   inv.addItem("SlotMachine", r[0], r[1], player, player);
  141. +                  
  142. +                   if (r[1] > 1)
  143. +                   {
  144. +                       systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  145. +                       systemMessage.addItemName(r[0]);
  146. +                       systemMessage.addItemNumber(r[1]);
  147. +                   }
  148. +                   else
  149. +                   {
  150. +                       systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  151. +                       systemMessage.addItemName(r[0]);
  152. +                   }
  153. +                   player.sendPacket(systemMessage);
  154. +               }
  155. +               else
  156. +               {
  157. +                   for (int i = 0; i < r[1]; ++i)
  158. +                   {
  159. +                       inv.addItem("SlotMachine", r[0], 1, player, player);
  160. +                       systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  161. +                       systemMessage.addItemName(r[0]);
  162. +                       player.sendPacket(systemMessage);
  163. +                   }
  164. +               }
  165. +           }
  166. +           showresult(player, true);
  167. +           player.useMagic(SkillTable.getInstance().getInfo(5965, 1), true, true);
  168. +       }
  169. +       else
  170. +       {
  171. +           showresult(player, false);
  172. +       }
  173. +       player.setIsImmobilized(false);
  174. +       player.win = false;
  175. +   }
  176. +  
  177. +   boolean checkstatus(L2PcInstance player)
  178. +   {
  179. +       if(player == null)
  180. +       {
  181. +           return false;
  182. +       }
  183. +       return true;
  184. +   }
  185. +  
  186. +   void run(L2PcInstance player) throws InterruptedException
  187. +   {
  188. +       int a = Rnd.get(10,30);
  189. +       int ar = a % 3;
  190. +       int b = Rnd.get(10,30);
  191. +       int br = b % 3;
  192. +       int c = Rnd.get(10,30);
  193. +       int i = 1;
  194. +       player.setIsImmobilized(true);
  195. +      
  196. +       while(i <= a)
  197. +       {
  198. +           if (!checkstatus(player))
  199. +           {
  200. +               return;
  201. +           }
  202. +          
  203. +           if(i % 3 == 0)
  204. +           {
  205. +               showpage(player, "a", "b", "c");
  206. +           }
  207. +           else if(i % 3 == 1)
  208. +           {
  209. +               showpage(player, "b", "b", "c");
  210. +           }
  211. +           else if(i % 3 == 2)
  212. +           {
  213. +               showpage(player, "c", "b", "c");
  214. +           }
  215. +           Thread.sleep(150);
  216. +           i++;
  217. +       }
  218. +      
  219. +       Thread.sleep(1000);
  220. +       i = 1;
  221. +       while(i <= b)
  222. +       {
  223. +           if (!checkstatus(player))
  224. +           {
  225. +               return;
  226. +           }
  227. +          
  228. +           if (ar == 0)
  229. +           {
  230. +               if(i % 3 == 0)
  231. +               {
  232. +                   showpage(player, "a", "b", "c");
  233. +               }              
  234. +               else if(i % 3 == 1)
  235. +               {
  236. +                   showpage(player, "a", "c", "c");
  237. +               }
  238. +               else if(i % 3 == 2)
  239. +               {
  240. +                   showpage(player, "a", "a", "c");
  241. +               }
  242. +           }
  243. +          
  244. +           else if (ar == 1)
  245. +           {
  246. +               if(i % 3 == 0)
  247. +               {
  248. +                   showpage(player, "b", "b", "c");
  249. +               }
  250. +               else if(i % 3 == 1)
  251. +               {
  252. +                   showpage(player, "b", "c", "c");
  253. +               }
  254. +               else if(i % 3 == 2)
  255. +               {
  256. +                   showpage(player, "b", "a", "c");
  257. +               }
  258. +           }
  259. +          
  260. +           else if (ar == 2)
  261. +           {
  262. +               if(i % 3 == 0)
  263. +               {
  264. +                   showpage(player, "c", "b", "c");
  265. +               }
  266. +               else if(i % 3 == 1)
  267. +               {
  268. +                   showpage(player, "c", "c", "c");
  269. +                   player.win = true;
  270. +               }
  271. +               else if(i % 3 == 2)
  272. +               {
  273. +                   showpage(player, "c", "a", "c");
  274. +               }
  275. +           }
  276. +           Thread.sleep(150);
  277. +           i++;
  278. +       }
  279. +      
  280. +       Thread.sleep(1000);
  281. +       i = 1;
  282. +       while(i <= c)
  283. +       {
  284. +           if (!checkstatus(player))
  285. +           {
  286. +               return;
  287. +           }
  288. +          
  289. +           if (br == 0)
  290. +           {
  291. +               if (ar == 0)
  292. +               {
  293. +                   if(i % 3 == 0)
  294. +                   {
  295. +                       showpage(player, "a", "b", "c");
  296. +                   }
  297. +                   else if(i % 3 == 1)
  298. +                   {
  299. +                       showpage(player, "a", "b", "a");
  300. +                   }
  301. +                   else if(i % 3 == 2)
  302. +                   {
  303. +                       showpage(player, "a", "b", "b");
  304. +                   }
  305. +               }
  306. +              
  307. +               else if (ar == 1)
  308. +               {
  309. +                   if(i % 3 == 0)
  310. +                   {
  311. +                       showpage(player, "b", "b", "c");
  312. +                   }
  313. +                   else if(i % 3 == 1)
  314. +                   {
  315. +                       showpage(player, "b", "b", "a");
  316. +                   }
  317. +                   else if(i % 3 == 2)
  318. +                   {
  319. +                       showpage(player, "b", "b", "b");
  320. +                       player.win = true;
  321. +                   }
  322. +               }
  323. +              
  324. +               else if (ar == 2)
  325. +               {
  326. +                   if(i % 3 == 0)
  327. +                   {
  328. +                       showpage(player, "c", "b", "c");
  329. +                   }
  330. +                   else if(i % 3 == 1)
  331. +                   {
  332. +                       showpage(player, "c", "b", "a");
  333. +                   }
  334. +                   else if(i % 3 == 2)
  335. +                   {
  336. +                       showpage(player, "c", "b", "b");
  337. +                   }
  338. +               }
  339. +           }
  340. +          
  341. +           else if (br == 1)
  342. +           {
  343. +               if (ar == 0)
  344. +               {
  345. +                   if(i % 3 == 0)
  346. +                   {
  347. +                       showpage(player, "a", "c", "c");
  348. +                   }
  349. +                   else if(i % 3 == 1)
  350. +                   {
  351. +                       showpage(player, "a", "c", "a");
  352. +                   }
  353. +                   else if(i % 3 == 2)
  354. +                   {
  355. +                       showpage(player, "a", "c", "b");
  356. +                   }
  357. +               }
  358. +              
  359. +               else if (ar == 1)
  360. +               {
  361. +                   if(i % 3 == 0)
  362. +                   {
  363. +                       showpage(player, "b", "c", "c");
  364. +                   }
  365. +                   else if(i % 3 == 1)
  366. +                   {
  367. +                       showpage(player, "b", "c", "a");
  368. +                   }
  369. +                   else if(i % 3 == 2)
  370. +                   {
  371. +                       showpage(player, "b", "c", "b");
  372. +                   }
  373. +               }
  374. +              
  375. +               else if (ar == 2)
  376. +               {
  377. +                   if(i % 3 == 0)
  378. +                   {
  379. +                       showpage(player, "c", "c", "c");
  380. +                       player.win = true;
  381. +                   }
  382. +                   else if(i % 3 == 1)
  383. +                   {
  384. +                       showpage(player, "c", "c", "a");
  385. +                   }
  386. +                   else if(i % 3 == 2)
  387. +                   {
  388. +                       showpage(player, "c", "c", "b");
  389. +                   }
  390. +               }
  391. +           }
  392. +          
  393. +           else if (br == 2)
  394. +           {
  395. +               if (ar == 0)
  396. +               {
  397. +                   if(i % 3 == 0)
  398. +                   {
  399. +                       showpage(player, "a", "a", "c");
  400. +                   }
  401. +                   else if(i % 3 == 1)
  402. +                   {
  403. +                       showpage(player, "a", "a", "a");
  404. +                       player.win = true;
  405. +                   }
  406. +                   else if(i % 3 == 2)
  407. +                   {
  408. +                       showpage(player, "a", "a", "b");
  409. +                   }
  410. +               }
  411. +              
  412. +               else if (ar == 1)
  413. +               {
  414. +                   if(i % 3 == 0)
  415. +                   {
  416. +                       showpage(player, "b", "a", "c");
  417. +                   }
  418. +                   else if(i % 3 == 1)
  419. +                   {
  420. +                       showpage(player, "b", "a", "a");
  421. +                   }
  422. +                   else if(i % 3 == 2)
  423. +                   {
  424. +                       showpage(player, "b", "a", "b");
  425. +                   }
  426. +               }
  427. +              
  428. +               else if (ar == 2)
  429. +               {
  430. +                   if(i % 3 == 0)
  431. +                   {
  432. +                       showpage(player, "c", "a", "c");
  433. +                   }
  434. +                   else if(i % 3 == 1)
  435. +                   {
  436. +                       showpage(player, "c", "a", "a");
  437. +                   }
  438. +                   else if(i % 3 == 2)
  439. +                   {
  440. +                       showpage(player, "c", "a", "b");
  441. +                   }
  442. +               }
  443. +           }
  444. +           Thread.sleep(150);
  445. +           i++;
  446. +       }
  447. +       Thread.sleep(2000);
  448. +      
  449. +       if(checkstatus(player))
  450. +       {
  451. +           checkresult(player);
  452. +       }
  453. +   }
  454. +  
  455. +   @Override
  456. +   public String onFirstTalk(L2Npc npc, L2PcInstance player)
  457. +   {
  458. +       showmain(player);
  459. +       return null;
  460. +   }
  461. +  
  462. +   void showpage(L2PcInstance activeChar, String a, String b, String c)
  463. +   {
  464. +       NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  465. +       TextBuilder replyMSG = new TextBuilder("<html><title>"+servername+" Slot Machine</title><body>");
  466. +       replyMSG.append("<center><img src=\"l2ui.squaregray\" width=290 height=1></center>");
  467. +        replyMSG.append("<center>" +
  468. +        "<table width=270 cellpadding=0 cellspacing=0>" +
  469. +           "<tr>" +
  470. +               "<td width=270>" + 
  471. +                   "<table width=270  height=50 cellspacing=0 cellpadding=0>" +
  472. +                       "<tr>");
  473. +           replyMSG.append("<td width=45>" +
  474. +                               "<center><img src=br_cashtex.item.br_cash_rune_of_rp_i00 width=32 height=32></center>" +
  475. +                           "</td>");
  476. +           replyMSG.append("<td width=170>" +         
  477. +                       "<center><font color=af9f47>Slot Machine Main Menu</font></center>");
  478. +           replyMSG.append("</td>" +
  479. +                           "<td width=32>" +
  480. +                       "<img src=br_cashtex.item.br_cash_rune_of_rp_i00 width=32 height=32>" +
  481. +                       "</td>" +
  482. +                   "</tr>" +
  483. +                   "</table>" +
  484. +                  
  485. +                   "<center><img src=\"l2ui.squaregray\" width=290 height=1></center><br>" +
  486. +                  
  487. +                   "<table width=270 height=30 bgcolor=5b574c cellspacing=0 cellpadding=7>" +
  488. +                       "<tr>" +
  489. +                           "<td valign=top>" +
  490. +                               "<table width=270 cellspacing=0 cellpadding=0>" +
  491. +                                   "<tr>");
  492. +                       replyMSG.append("<td><center>Playing with SlotMachine...</center>" +
  493. +                                       "</td>" +
  494. +                                   "</tr>" +
  495. +                               "</table>" +
  496. +                           "</td>" +
  497. +                       "</tr>" +
  498. +                   "</table>");
  499. +  
  500. +                   replyMSG.append("<br><center><img src=\"l2ui.squaregray\" width=290 height=1></center><br>" +
  501. +                  
  502. +                   "<table width=270 height=30 cellpadding=0 cellspacing=0 valign=top>" +
  503. +                       "<tr>" +
  504. +                           "<td>" +
  505. +                               "<table width=270 height=40 bgcolor=090908 cellspacing=0 cellpadding=7>" +
  506. +                                   "<tr>" +
  507. +                                       "<td valign=top>" +
  508. +                                           "<table width=270 cellspacing=0 cellpadding=0>" +
  509. +                                               "<tr>");
  510. +                                       replyMSG.append("<td height=24 valign=top>" +
  511. +                                                       "<center>" +
  512. +                                                       "<table cellspacing=-1>" +
  513. +                                                           "<tr>" +
  514. +                                                               "<td><img src=\"icon.etc_dice_"+a+"_i00\" " +
  515. +                                                                   "width=32 height=32>" +
  516. +                                                               "</td>" +
  517. +                                                               "<td>" +
  518. +                                                                   "<img src=\"icon.etc_dice_"+b+"_i00\" width=32 height=32>" +
  519. +                                                               "</td>" +
  520. +                                                               "<td>" +
  521. +                                                                   "<img src=\"icon.etc_dice_"+c+"_i00\" width=32 height=32>" +
  522. +                                                               "</td>" +
  523. +                                                           "</tr>" +
  524. +                                                       "</table>" +
  525. +                                                       "</center><br><br>");
  526. +                                       replyMSG.append("</td><br>" +
  527. +                                           "<br></tr>" +
  528. +                                           "</table>" +
  529. +                                       "</td>" +
  530. +                                   "</tr>" +
  531. +                               "</table>" +
  532. +                           "</td>" +
  533. +                       "</tr>" +
  534. +                   "</table>" +
  535. +                  
  536. +                   "<br><br><center><img src=\"l2ui.squaregray\" width=290 height=1></center><br>");
  537. +        
  538. +        replyMSG.append("<center><table width=270>" +
  539. +                                   "<tr>" +
  540. +                                       "<td width=270>" +
  541. +                                           "<center><font color=444444>By Wyatt</color><br>" +
  542. +                                           "</center>" +
  543. +                                       "</td>" +
  544. +                                   "</tr>" +
  545. +                               "</table></center>");
  546. +        replyMSG.append("</tr>" +
  547. +               "</td>" +
  548. +           "</table>" +
  549. +           "</center>");
  550. +       replyMSG.append("</body></html>");
  551. +        adminReply.setHtml(replyMSG.toString());
  552. +        activeChar.sendPacket(adminReply);    
  553. +   }
  554. +  
  555. +   void showmain(L2PcInstance activeChar)
  556. +   {
  557. +       NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  558. +       TextBuilder replyMSG = new TextBuilder("<html><title>"+servername+" Slot Machine</title><body>");
  559. +       replyMSG.append("<center><img src=\"l2ui.squaregray\" width=290 height=1></center>");
  560. +        replyMSG.append("<center>" +
  561. +        "<table width=270 cellpadding=0 cellspacing=0>" +
  562. +           "<tr>" +
  563. +               "<td width=270>" + 
  564. +                   "<table width=270  height=50 cellspacing=0 cellpadding=0>" +
  565. +                       "<tr>");
  566. +           replyMSG.append("<td width=45>" +
  567. +                               "<center><img src=br_cashtex.item.br_cash_rune_of_rp_i00 width=32 height=32></center>" +
  568. +                           "</td>");
  569. +           replyMSG.append("<td width=170>" +         
  570. +                       "<center><font color=af9f47>Slot Machine Main Menu</font></center>");
  571. +           replyMSG.append("</td>" +
  572. +                           "<td width=32>" +
  573. +                       "<img src=br_cashtex.item.br_cash_rune_of_rp_i00 width=32 height=32>" +
  574. +                       "</td>" +
  575. +                   "</tr>" +
  576. +                   "</table>" +
  577. +                  
  578. +                   "<center><img src=\"l2ui.squaregray\" width=290 height=1></center><br>" +
  579. +                  
  580. +                   "<table width=270 height=30 bgcolor=5b574c cellspacing=0 cellpadding=7>" +
  581. +                       "<tr>" +
  582. +                           "<td valign=top>" +
  583. +                               "<table width=270 cellspacing=0 cellpadding=0>" +
  584. +                                   "<tr>");
  585. +                       replyMSG.append("<td><center>Do you want to play?</center>" +
  586. +                                       "</td>" +
  587. +                                   "</tr>" +
  588. +                               "</table>" +
  589. +                           "</td>" +
  590. +                       "</tr>" +
  591. +                   "</table>");
  592. +  
  593. +                   replyMSG.append("<br><center><img src=\"l2ui.squaregray\" width=290 height=1></center><br>" +
  594. +                  
  595. +                   "<table width=270 height=30 cellpadding=0 cellspacing=0 valign=top>" +
  596. +                       "<tr>" +
  597. +                           "<td>" +
  598. +                               "<table width=270 height=40 bgcolor=090908 cellspacing=0 cellpadding=7>" +
  599. +                                   "<tr>" +
  600. +                                       "<td valign=top>" +
  601. +                                           "<table width=270 cellspacing=0 cellpadding=0>" +
  602. +                                               "<tr>");
  603. +                                   replyMSG.append("<td height=24 valign=top>Hi <font color=LEVEL>"+activeChar.getName()+"</font>! Here you are inside SlotMachine event." +
  604. +                                           " Every time that you play here you will waste:<br>");
  605. +                                   for (int[] feeds : feed)
  606. +                                   {
  607. +                                       replyMSG.append("-<font color=LEVEL>"+feeds[1]+"</font> of <font color=LEVEL>"+ItemTable.getInstance().createDummyItem(feeds[0]).getItemName()+"</font><br>");
  608. +                                   }  
  609. +                                  
  610. +                                   replyMSG.append("<center><button value=\"Lets Play\" action=\"bypass -h Quest SlotMachine play\" width=70 height=30 " +
  611. +                                       "back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center><br>");
  612. +                               replyMSG.append("</td><br></tr>" +
  613. +                                           "</table>" +
  614. +                                       "</td>" +
  615. +                                   "</tr>" +
  616. +                               "</table>" +
  617. +                           "</td>" +
  618. +                       "</tr>" +
  619. +                   "</table>" +
  620. +                  
  621. +                   "<br><br><center><img src=\"l2ui.squaregray\" width=290 height=1></center><br>");
  622. +        
  623. +        replyMSG.append("<center><table width=270>" +
  624. +                                   "<tr>" +
  625. +                                       "<td width=270>" +
  626. +                                           "<center><font color=444444>By Wyatt</color><br>" +
  627. +                                           "</center>" +
  628. +                                       "</td>" +
  629. +                                   "</tr>" +
  630. +                               "</table></center>");
  631. +        replyMSG.append("</tr>" +
  632. +               "</td>" +
  633. +           "</table>" +
  634. +           "</center>");
  635. +       replyMSG.append("</body></html>");
  636. +        adminReply.setHtml(replyMSG.toString());
  637. +        activeChar.sendPacket(adminReply);    
  638. +   }
  639. +  
  640. +   void showresult(L2PcInstance activeChar, boolean l)
  641. +   {      
  642. +       String result ="";
  643. +       if(l)
  644. +       {
  645. +           result = "Congratulations you won!";
  646. +       }
  647. +       else
  648. +       {
  649. +           result = "I'm sorry you lost...";
  650. +       }
  651. +       NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  652. +       TextBuilder replyMSG = new TextBuilder("<html><title>"+servername+" Slot Machine</title><body>");
  653. +       replyMSG.append("<center><img src=\"l2ui.squaregray\" width=290 height=1></center>");
  654. +        replyMSG.append("<center>" +
  655. +        "<table width=270 cellpadding=0 cellspacing=0>" +
  656. +           "<tr>" +
  657. +               "<td width=270>" + 
  658. +                   "<table width=270  height=50 cellspacing=0 cellpadding=0>" +
  659. +                       "<tr>");
  660. +           replyMSG.append("<td width=45>" +
  661. +                               "<center><img src=br_cashtex.item.br_cash_rune_of_rp_i00 width=32 height=32></center>" +
  662. +                           "</td>");
  663. +           replyMSG.append("<td width=170>" +         
  664. +                       "<center><font color=af9f47>Slot Machine Main Menu</font></center>");
  665. +           replyMSG.append("</td>" +
  666. +                           "<td width=32>" +
  667. +                       "<img src=br_cashtex.item.br_cash_rune_of_rp_i00 width=32 height=32>" +
  668. +                       "</td>" +
  669. +                   "</tr>" +
  670. +                   "</table>" +
  671. +                  
  672. +                   "<center><img src=\"l2ui.squaregray\" width=290 height=1></center><br>" +
  673. +                  
  674. +                   "<table width=270 height=30 bgcolor=5b574c cellspacing=0 cellpadding=7>" +
  675. +                       "<tr>" +
  676. +                           "<td valign=top>" +
  677. +                               "<table width=270 cellspacing=0 cellpadding=0>" +
  678. +                                   "<tr>");
  679. +          
  680. +                       replyMSG.append("<td><center>"+result+"</center>" +
  681. +                                       "</td>" +
  682. +                                   "</tr>" +
  683. +                               "</table>" +
  684. +                           "</td>" +
  685. +                       "</tr>" +
  686. +                   "</table>");
  687. +  
  688. +                   replyMSG.append("<br><center><img src=\"l2ui.squaregray\" width=290 height=1></center><br>" +
  689. +                  
  690. +                   "<table width=270 height=30 cellpadding=0 cellspacing=0 valign=top>" +
  691. +                       "<tr>" +
  692. +                           "<td>" +
  693. +                               "<table width=270 height=40 bgcolor=090908 cellspacing=0 cellpadding=7>" +
  694. +                                   "<tr>" +
  695. +                                       "<td valign=top>" +
  696. +                                           "<table width=270 cellspacing=0 cellpadding=0>" +
  697. +                                               "<tr>");
  698. +                                   replyMSG.append("<td height=24 valign=top>Do you want to play again <font color=LEVEL>"+activeChar.getName()+"</font>?");
  699. +                                   replyMSG.append("<center><button value=\"Lets Play\" action=\"bypass -h Quest SlotMachine play\" width=70 height=30 " +
  700. +                                       "back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center><br>");
  701. +                               replyMSG.append("</td><br></tr>" +
  702. +                                           "</table>" +
  703. +                                       "</td>" +
  704. +                                   "</tr>" +
  705. +                               "</table>" +
  706. +                           "</td>" +
  707. +                       "</tr>" +
  708. +                   "</table>" +
  709. +                  
  710. +                   "<br><br><center><img src=\"l2ui.squaregray\" width=290 height=1></center><br>");
  711. +        
  712. +        replyMSG.append("<center><table width=270>" +
  713. +                                   "<tr>" +
  714. +                                       "<td width=270>" +
  715. +                                           "<center><font color=444444>By Wyatt</color><br>" +
  716. +                                           "</center>" +
  717. +                                       "</td>" +
  718. +                                   "</tr>" +
  719. +                               "</table></center>");
  720. +        replyMSG.append("</tr>" +
  721. +               "</td>" +
  722. +           "</table>" +
  723. +           "</center>");
  724. +       replyMSG.append("</body></html>");
  725. +        adminReply.setHtml(replyMSG.toString());
  726. +        activeChar.sendPacket(adminReply);
  727. +   }
  728. +  
  729. +   void loadConfigs()
  730. +   {
  731. +       try
  732. +       {
  733. +           Properties prop = new Properties();
  734. +           prop.load(new FileInputStream(new File("./config/SlotMachine.properties")));
  735. +           servername = prop.getProperty("ServerName", "Hidden");
  736. +           npcid = Integer.parseInt(prop.getProperty("NpcId", "100"));
  737. +           rewards = new ArrayList<>();
  738. +           String[] propertySplit = prop.getProperty("Rewards", "57,100").split(";");
  739. +          
  740. +           for (String reward : propertySplit)
  741. +           {
  742. +               String[] rewardSplit = reward.split(",");
  743. +              
  744. +               if (rewardSplit.length != 2)
  745. +               {
  746. +                   _log.warning(StringUtil.concat("SlotMachine invalid config property -> Reward \"", reward, "\""));
  747. +               }
  748. +               else
  749. +               {
  750. +                   try
  751. +                   {
  752. +                       rewards.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
  753. +                   }
  754. +                   catch (NumberFormatException nfe)
  755. +                   {
  756. +                       if (!reward.isEmpty())
  757. +                       {
  758. +                           _log.warning(StringUtil.concat("SlotMachine invalid config property -> Reward \"", reward, "\""));
  759. +                       }
  760. +                   }
  761. +               }
  762. +           }  
  763. +           feed = new ArrayList<>();
  764. +           propertySplit = prop.getProperty("Feed", "57,1").split(";");
  765. +          
  766. +           for (String feeds : propertySplit)
  767. +           {
  768. +               String[] feedSplit = feeds.split(",");
  769. +               if (feedSplit.length != 2)
  770. +               {
  771. +                   _log.warning(StringUtil.concat("SlotMachine invalid config property -> Feed \"", feeds, "\""));
  772. +               }
  773. +               else
  774. +               {
  775. +                   try
  776. +                   {
  777. +                       feed.add(new int[]{Integer.parseInt(feedSplit[0]), Integer.parseInt(feedSplit[1])});
  778. +                   }
  779. +                   catch (NumberFormatException nfe)
  780. +                   {
  781. +                       if (!feeds.isEmpty())
  782. +                       {
  783. +                           _log.warning(StringUtil.concat("SlotMachine invalid config property -> Feed \"", feeds, "\""));
  784. +                       }
  785. +                   }
  786. +               }
  787. +           }  
  788. +       }
  789. +       catch(Exception e)
  790. +       {
  791. +           e.printStackTrace();
  792. +       }
  793. +   }  
  794. +  
  795. +   public static void main(String args[])
  796. +   {
  797. +       new SlotMachine(-1, qn, "custom");
  798. +   }
  799. +}
  800. \ No newline at end of file
  801. Index: dist/game/data/scripts.cfg
  802. ===================================================================
  803. --- dist/game/data/scripts.cfg  (revision 9467)
  804. +++ dist/game/data/scripts.cfg  (working copy)
  805. @@ -686,6 +686,7 @@
  806.  quests/Q10291_FireDragonDestroyer/Q10291_FireDragonDestroyer.java
  807.  
  808.  # Custom
  809. +custom/SlotMachine/SlotMachine.java
  810.  custom/FortuneTelling/FortuneTelling.java
  811.  custom/Nottingale/Nottingale.java
  812.  custom/EchoCrystals/EchoCrystals.java
Advertisement
Add Comment
Please, Sign In to add comment