Advertisement
Guest User

Special Apparel Shop

a guest
Apr 30th, 2017
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.44 KB | None | 0 0
  1. --[[
  2.  |--------------------------------------------------------|
  3.  | Script Name: Special Apparel Shop                      |
  4.  |--------------------------------------------------------|
  5.  | By: Eviles (Satan)                                     |
  6.  |--------------------------------------------------------|
  7.  | Thanks to: Undead Pirates Online, Billy.
  8.  | Version 1.0                                            |
  9.  |--------------------------------------------------------|
  10.  | Description: A organizated apparel shop script where   |
  11.  | the player can try the apparel before purchase it.     |
  12.  |--------------------------------------------------------|
  13.  | Change-Logs:                                           |
  14.  | - Script Created (08/12/2016)                          |
  15.  | - Fixed NPC Talks [Eviles]                             |
  16.  | - Created ApparelShop.Init()                           |
  17.  | - Created ApparelShop.BuyPage()                        |
  18.  | - Created ApparelShop.Purchase()                       |
  19.  | - Fixed ApparelShop.SummonMob()                        |
  20.  | - Fixed and hooked SpecialAppMob()                     |
  21.  | - Created tables for npc talk, apparels.               |
  22.  |--------------------------------------------------------|
  23.  
  24.     * Installation:
  25.    
  26.     # Put the following on NpcSdk.lua, MsgProc():
  27.    
  28.         elseif item.func == ApparelShop.Purchase then
  29.             return ApparelShop.Purchase( character,item.p1)
  30.            
  31.     # Put the following at MissionSdk.lua, ActionsProc():
  32.  
  33.         elseif actions[i].func == ApparelShop.SummonMob then
  34.                 local ret = ApparelShop.SummonMob(character,actions[i].p1,actions[i].p2)
  35.                 if ret ~= LUA_TRUE then
  36.                 return LUA_FALSE
  37.             end    
  38.  
  39.     * Sample of a mob model line, monster must be equipped with apparel of course;
  40.         1314    1314-Lance Model    Dry Eye 1   2   0   0   100 6665    0255    6666    6667    6668    0   0   0   0   0   0   1   1   100 182 -1  -1  0   0   0   0   1.051   1.369   2.599   40  1,5 2   399 398 0   0   0   1   1   0   0   25  100 0,-1,-1,-1,-1,-1,-1,-1,-1,-1    0,-1,-1,-1,-1,-1,-1,-1,-1,-1    0   0   0   0,-1,-1,-1,-1,-1,-1,-1,-1,-1    0,-1,-1,-1,-1,-1,-1,-1,-1,-1    0   1   1000    0   0   1   0   1   40  0   18  0   4   5   0   3   2   1   1   0   1   1   1442    0   1500    480 0   5   5   5   5   5   5   20  0   0   0   0   20  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   1.0,1.0,1.0
  41.    
  42. --]]
  43. print("* Loading <AppShop> init.lua")
  44.  
  45. ApparelShop = {}
  46. SpecialApp = {}
  47. SpecialAppMob = {}
  48. ApparelShop.Card = 7901
  49. modelsummoned = 0
  50. ApparelShop.Talk = {
  51.     "Apparel Shop: Welcome to the New Fashion Shop! Check My New Apparels!",
  52.     "New Apparels List",
  53.     "Apparel Shop: The Shop offers a variety of exclusive apparels only, select below what kind of apparel you want or wanna try.",
  54.     "[Next]",
  55.     "Confirm...",  
  56.     "Try Apparel...",  
  57.     "[Back]",  
  58.     "Apparel Shop: I'm sorry, but seems your inventory is full!",
  59.     "Apparel Shop: Please make sure you got Special Apparel Cards...",
  60.     "Apparel Shop: Another model is arealdy summoned!",
  61.     };
  62.  
  63. -- Set = Pieces of app, Price = Cards needed, chaType = Character Type, Monster = App Model ID(Characterinfo.txt);
  64. -- SpecialApp[ChestID]
  65. SpecialApp[7764] = {Set = {6665,6666,6667,6668},Price = 1,chaType = 1,Monster = 1314}
  66. SpecialApp[7765] = {Set = {6669,6670,6671,6672},Price = 1,chaType = 1,Monster = 1315}
  67. SpecialApp[7766] = {Set = {6673,6674,6675,6676},Price = 1,chaType = 1,Monster = 1316}
  68. SpecialApp[7767] = {Set = {6677,6678,6679,6680},Price = 1,chaType = 1,Monster = 1317}
  69. SpecialApp[7768] = {Set = {6681,6682,6683,6684},Price = 1,chaType = 1,Monster = 1318}
  70. SpecialApp[7769] = {Set = {6708,6709,6710,6711},Price = 1,chaType = 1,Monster = 1319}
  71. SpecialApp[7770] = {Set = {6712,6713,6714,6715},Price = 1,chaType = 1,Monster = 1320}
  72. SpecialApp[7771] = {Set = {6732,6733,6734,6735},Price = 1,chaType = 1,Monster = 1336}
  73. SpecialApp[7772] = {Set = {6736,6737,6738,6739},Price = 1,chaType = 1,Monster = 1321}
  74. SpecialApp[7773] = {Set = {6740,6741,6742,6743},Price = 1,chaType = 1,Monster = 1322}
  75. SpecialApp[7774] = {Set = {6748,6749,6750,6751},Price = 1,chaType = 1,Monster = 1323}
  76. SpecialApp[7775] = {Set = {6768,6769,6770,6771},Price = 1,chaType = 1,Monster = 1324}
  77. SpecialApp[7776] = {Set = {6772,6773,6774,6775},Price = 1,chaType = 1,Monster = 1325}
  78. SpecialApp[7785] = {Set = {6665,6666,6667,6668},Price = 1,chaType = 2,Monster = 1337}
  79. SpecialApp[7786] = {Set = {6669,6670,6671,6672},Price = 1,chaType = 2,Monster = 1338}
  80. SpecialApp[7787] = {Set = {6673,6674,6675,6676},Price = 1,chaType = 2,Monster = 1339}
  81. SpecialApp[7788] = {Set = {6677,6678,6679,6680},Price = 1,chaType = 2,Monster = 1340}
  82. SpecialApp[7789] = {Set = {6681,6682,6683,6684},Price = 1,chaType = 2,Monster = 1341}
  83. SpecialApp[7790] = {Set = {6708,6709,6710,6711},Price = 1,chaType = 2,Monster = 1342}
  84. SpecialApp[7791] = {Set = {6724,6725,6726,6727},Price = 1,chaType = 2,Monster = 1343}
  85. SpecialApp[7792] = {Set = {6756,6757,6758,6759},Price = 1,chaType = 2,Monster = 1344}
  86. SpecialApp[7793] = {Set = {6764,6765,6766,6767},Price = 1,chaType = 2,Monster = 1345}
  87. SpecialApp[7794] = {Set = {6776,6777,6778,6779},Price = 1,chaType = 2,Monster = 1346}
  88. SpecialApp[7795] = {Set = {6780,6781,6782,6783},Price = 1,chaType = 2,Monster = 1347}
  89. SpecialApp[7796] = {Set = {6792,6793,6794,6795},Price = 1,chaType = 2,Monster = 1348}
  90. SpecialApp[7797] = {Set = {6806,6807,6808,6809},Price = 1,chaType = 2,Monster = 1349}
  91. SpecialApp[7798] = {Set = {6810,6811,6812,6813},Price = 1,chaType = 2,Monster = 1350}
  92. SpecialApp[7799] = {Set = {6032,6033,6034,6035},Price = 1,chaType = 2,Monster = 1351}
  93. SpecialApp[7800] = {Set = {6036,6037,6038,6039},Price = 1,chaType = 2,Monster = 1352}
  94. SpecialApp[7837] = {Set = {6294,6295,6296},Price = 1,chaType = 2,Monster = 1354}
  95. SpecialApp[7831] = {Set = {6262,6263,6264,6265},Price = 1,chaType = 2,Monster = 1355}
  96. SpecialApp[6107] = {Set = {5335,5336,5337,5338},Price = 1,chaType = 2,Monster = 1357}
  97.  
  98. PadStringText = function(str)
  99.     local Len = string.len(str)
  100.     local Lines = math.ceil(Len/42)
  101.     if Len == 42 then
  102.         return str
  103.     end
  104.     if Len < 42 then
  105.         for i = 1,42-Len do
  106.             str = str.." "
  107.         end
  108.     end
  109.     return str
  110. end
  111.  
  112. -- Usage: ApparelShop.Init(chaType);
  113. ApparelShop.Init = function(req)
  114.     local page, count, total = 2, 0, 0
  115.     for i,v in pairs(SpecialApp) do
  116.         total = total + 1
  117.     end
  118.     local pages = math.ceil(total/7) + 2
  119.     for i,v in pairs(SpecialApp) do
  120.         if count == 7 then
  121.             Text(page,ApparelShop.Talk[4],JumpPage,page + 1)
  122.             page = page + 1
  123.             Talk(page,ApparelShop.Talk[3])
  124.             count = 0
  125.         end
  126.         if(v.chaType == req or v.chaType == 0)then         
  127.             Text(page,GetItemName(i),JumpPage,pages)
  128.             ApparelShop.BuyPage(pages,i,page)
  129.             pages = pages + 1
  130.             count = count + 1
  131.         end
  132.     end
  133. end
  134.  
  135. ApparelShop.BuyPage = function(page,i,backPage)
  136.     local SetName, Price = GetItemName(i), SpecialApp[i].Price
  137.     local firstLine = PadStringText("Apparel Shop: "..SetName..", will cost you "..Price.."x Special Apparel Card.")
  138.     InitTrigger()
  139.     TriggerAction( 1, ApparelShop.SummonMob, SpecialApp[i].Monster,i)      
  140.     Talk(page,firstLine)
  141.     Text(page,ApparelShop.Talk[5], ApparelShop.Purchase,i)
  142.     Text(page,ApparelShop.Talk[6], MultiTrigger, GetMultiTrigger(), 1)
  143.     Text(page,ApparelShop.Talk[7],JumpPage,backPage)
  144. end
  145.  
  146. ApparelShop.Purchase = function(r,i)
  147.     local Price, Qty = SpecialApp[i].Price, 1
  148.     local SetName = GetItemName(i)
  149.     if(GetChaFreeBagGridNum(r) < Qty)then
  150.         HelpInfo(r,0,ApparelShop.Talk[8])
  151.         return 0
  152.     end
  153.     local Card = CheckBagItem(r,ApparelShop.Card)
  154.     if(Card < Price)then
  155.         HelpInfo(r,0,ApparelShop.Talk[9])
  156.         return 0
  157.     end
  158.     HelpInfo(r,0,"Apparel Shop: Enjoy your new apparel, "..GetChaDefaultName(r).."!")      
  159.     TakeItem(r, 0, ApparelShop.Card, Qty)
  160.     GiveItem(r, 0, i, Qty, 4)
  161. end
  162.  
  163. ApparelShop.SummonMob = function(r,m,s)
  164.     if modelsummoned ~= 1 then
  165.     local modelRole = CreateChaX(m, 38100, 59500, 0, 1900000, r)   
  166.         SetChaLifeTime( modelRole, 7200000 )
  167.         modelsummoned = 1
  168.         SpecialAppMob = {summoner = r, step = 1,SetName=GetItemName(s),summoned = 1,monsterrole = modelRole}
  169.     else
  170.         HelpInfo(r,0,ApparelShop.Talk[10])
  171.     end
  172. end
  173.  
  174. -- Put body of function in cha_timer if you don't use hooks and disable it;
  175. function ApparelMonsterModel(ignore,role)
  176.     if(IsPlayer(role) == 1)then
  177.         if(SpecialAppMob ~= nil)then
  178.             if(SpecialAppMob.monsterrole ~= nil)then
  179.                 if(CheckMonsterDead(SpecialAppMob.monsterrole) ~= 1)then
  180.                     if(SpecialAppMob.step == 1)then
  181.                         Say(SpecialAppMob.monsterrole,""..GetChaDefaultName(SpecialAppMob.monsterrole)..": Hello "..GetChaDefaultName(SpecialAppMob.summoner).."!")
  182.                     elseif SpecialAppMob.step == 5 then
  183.                         Say(SpecialAppMob.monsterrole,""..GetChaDefaultName(SpecialAppMob.monsterrole)..": This is "..SpecialAppMob.SetName.."!")
  184.                     elseif SpecialAppMob.step == 9 then
  185.                         ChaMove(SpecialAppMob.monsterrole,38125,58625)
  186.                     elseif SpecialAppMob.step == 13 then
  187.                         ChaMove(SpecialAppMob.monsterrole,38100,59500)
  188.                     elseif SpecialAppMob.step == 17 then
  189.                         Say(SpecialAppMob.monsterrole,""..GetChaDefaultName(SpecialAppMob.monsterrole)..": Bye!")
  190.                         modelsummoned = 0
  191.                         KillCha(SpecialAppMob.monsterrole)
  192.                     end
  193.                     SpecialAppMob.step = SpecialAppMob.step + 1
  194.                 else
  195.                     SpecialAppMob = nil
  196.                     modelsummoned = 0
  197.                 end
  198.             end
  199.         end
  200.     end
  201. end
  202.  
  203. -- Global function, after define the table SpecialApp use this for chest usage;
  204. function SpecialApparel( role, Item )
  205.     local ItemID = GetItemID(Item)
  206.     local NocLock   = KitbagLock(role, 0)
  207.     if NocLock == LUA_FALSE then
  208.         SystemNotice(role,"Your inventory is being binded.")
  209.         UseItemFailed(role)
  210.         return
  211.     end
  212.     local Cha_Boat  = 0
  213.     Cha_Boat = GetCtrlBoat(role)
  214.     if Cha_Boat ~= nil then
  215.         SystemNotice(role,"Cannot use while sailing")
  216.         UseItemFailed (role)
  217.         return
  218.     end
  219.     local Cha           = TurnToCha(role)
  220.     local ItemCanGet    = GetChaFreeBagGridNum(Cha)
  221.     local SlotNeed      = 5
  222.     if ItemCanGet < SlotNeed then
  223.         SystemNotice(Cha,"Requires "..SlotNeed.." slots in inventory to open "..GetItemName(ItemID))
  224.         UseItemFailed(Cha)
  225.         return
  226.     end
  227.     local ItemID = GetItemID(Item)
  228.     local item_name = GetItemName(ItemID)
  229.     if(SpecialApp[ItemID]~= nil)then
  230.         for i,v in pairs(SpecialApp[ItemID].Set)do
  231.             GiveItem ( role , 0 , v , 1 , 4 )
  232.         end
  233.     end
  234. end
  235.  
  236. -----------------------
  237. --New Apparel - Lance--
  238. -----------------------
  239. function npc_spc01()
  240.     Talk( 1, ApparelShop.Talk[1] )
  241.     Text( 1, ApparelShop.Talk[2], JumpPage, 2 )
  242.     Talk( 2, ApparelShop.Talk[3])
  243.     ApparelShop.Init(1)
  244. end
  245.  
  246. -------------------------
  247. --New Apparel - Carsise--
  248. -------------------------
  249. function npc_spc02()
  250.     Talk( 1, ApparelShop.Talk[1] )
  251.     Text( 1, ApparelShop.Talk[2], JumpPage, 2 )
  252.     Talk( 2, ApparelShop.Talk[3])
  253.     ApparelShop.Init(2)
  254. end
  255.  
  256. Hook:AddPostHook("custom_cha_timer",ApparelMonsterModel) -- Disable if don't use hooks;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement