Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- |--------------------------------------------------------|
- | Script Name: Special Apparel Shop |
- |--------------------------------------------------------|
- | By: Eviles (Satan) |
- |--------------------------------------------------------|
- | Thanks to: Undead Pirates Online, Billy.
- | Version 1.0 |
- |--------------------------------------------------------|
- | Description: A organizated apparel shop script where |
- | the player can try the apparel before purchase it. |
- |--------------------------------------------------------|
- | Change-Logs: |
- | - Script Created (08/12/2016) |
- | - Fixed NPC Talks [Eviles] |
- | - Created ApparelShop.Init() |
- | - Created ApparelShop.BuyPage() |
- | - Created ApparelShop.Purchase() |
- | - Fixed ApparelShop.SummonMob() |
- | - Fixed and hooked SpecialAppMob() |
- | - Created tables for npc talk, apparels. |
- |--------------------------------------------------------|
- * Installation:
- # Put the following on NpcSdk.lua, MsgProc():
- elseif item.func == ApparelShop.Purchase then
- return ApparelShop.Purchase( character,item.p1)
- # Put the following at MissionSdk.lua, ActionsProc():
- elseif actions[i].func == ApparelShop.SummonMob then
- local ret = ApparelShop.SummonMob(character,actions[i].p1,actions[i].p2)
- if ret ~= LUA_TRUE then
- return LUA_FALSE
- end
- * Sample of a mob model line, monster must be equipped with apparel of course;
- 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
- --]]
- print("* Loading <AppShop> init.lua")
- ApparelShop = {}
- SpecialApp = {}
- SpecialAppMob = {}
- ApparelShop.Card = 7901
- modelsummoned = 0
- ApparelShop.Talk = {
- "Apparel Shop: Welcome to the New Fashion Shop! Check My New Apparels!",
- "New Apparels List",
- "Apparel Shop: The Shop offers a variety of exclusive apparels only, select below what kind of apparel you want or wanna try.",
- "[Next]",
- "Confirm...",
- "Try Apparel...",
- "[Back]",
- "Apparel Shop: I'm sorry, but seems your inventory is full!",
- "Apparel Shop: Please make sure you got Special Apparel Cards...",
- "Apparel Shop: Another model is arealdy summoned!",
- };
- -- Set = Pieces of app, Price = Cards needed, chaType = Character Type, Monster = App Model ID(Characterinfo.txt);
- -- SpecialApp[ChestID]
- SpecialApp[7764] = {Set = {6665,6666,6667,6668},Price = 1,chaType = 1,Monster = 1314}
- SpecialApp[7765] = {Set = {6669,6670,6671,6672},Price = 1,chaType = 1,Monster = 1315}
- SpecialApp[7766] = {Set = {6673,6674,6675,6676},Price = 1,chaType = 1,Monster = 1316}
- SpecialApp[7767] = {Set = {6677,6678,6679,6680},Price = 1,chaType = 1,Monster = 1317}
- SpecialApp[7768] = {Set = {6681,6682,6683,6684},Price = 1,chaType = 1,Monster = 1318}
- SpecialApp[7769] = {Set = {6708,6709,6710,6711},Price = 1,chaType = 1,Monster = 1319}
- SpecialApp[7770] = {Set = {6712,6713,6714,6715},Price = 1,chaType = 1,Monster = 1320}
- SpecialApp[7771] = {Set = {6732,6733,6734,6735},Price = 1,chaType = 1,Monster = 1336}
- SpecialApp[7772] = {Set = {6736,6737,6738,6739},Price = 1,chaType = 1,Monster = 1321}
- SpecialApp[7773] = {Set = {6740,6741,6742,6743},Price = 1,chaType = 1,Monster = 1322}
- SpecialApp[7774] = {Set = {6748,6749,6750,6751},Price = 1,chaType = 1,Monster = 1323}
- SpecialApp[7775] = {Set = {6768,6769,6770,6771},Price = 1,chaType = 1,Monster = 1324}
- SpecialApp[7776] = {Set = {6772,6773,6774,6775},Price = 1,chaType = 1,Monster = 1325}
- SpecialApp[7785] = {Set = {6665,6666,6667,6668},Price = 1,chaType = 2,Monster = 1337}
- SpecialApp[7786] = {Set = {6669,6670,6671,6672},Price = 1,chaType = 2,Monster = 1338}
- SpecialApp[7787] = {Set = {6673,6674,6675,6676},Price = 1,chaType = 2,Monster = 1339}
- SpecialApp[7788] = {Set = {6677,6678,6679,6680},Price = 1,chaType = 2,Monster = 1340}
- SpecialApp[7789] = {Set = {6681,6682,6683,6684},Price = 1,chaType = 2,Monster = 1341}
- SpecialApp[7790] = {Set = {6708,6709,6710,6711},Price = 1,chaType = 2,Monster = 1342}
- SpecialApp[7791] = {Set = {6724,6725,6726,6727},Price = 1,chaType = 2,Monster = 1343}
- SpecialApp[7792] = {Set = {6756,6757,6758,6759},Price = 1,chaType = 2,Monster = 1344}
- SpecialApp[7793] = {Set = {6764,6765,6766,6767},Price = 1,chaType = 2,Monster = 1345}
- SpecialApp[7794] = {Set = {6776,6777,6778,6779},Price = 1,chaType = 2,Monster = 1346}
- SpecialApp[7795] = {Set = {6780,6781,6782,6783},Price = 1,chaType = 2,Monster = 1347}
- SpecialApp[7796] = {Set = {6792,6793,6794,6795},Price = 1,chaType = 2,Monster = 1348}
- SpecialApp[7797] = {Set = {6806,6807,6808,6809},Price = 1,chaType = 2,Monster = 1349}
- SpecialApp[7798] = {Set = {6810,6811,6812,6813},Price = 1,chaType = 2,Monster = 1350}
- SpecialApp[7799] = {Set = {6032,6033,6034,6035},Price = 1,chaType = 2,Monster = 1351}
- SpecialApp[7800] = {Set = {6036,6037,6038,6039},Price = 1,chaType = 2,Monster = 1352}
- SpecialApp[7837] = {Set = {6294,6295,6296},Price = 1,chaType = 2,Monster = 1354}
- SpecialApp[7831] = {Set = {6262,6263,6264,6265},Price = 1,chaType = 2,Monster = 1355}
- SpecialApp[6107] = {Set = {5335,5336,5337,5338},Price = 1,chaType = 2,Monster = 1357}
- PadStringText = function(str)
- local Len = string.len(str)
- local Lines = math.ceil(Len/42)
- if Len == 42 then
- return str
- end
- if Len < 42 then
- for i = 1,42-Len do
- str = str.." "
- end
- end
- return str
- end
- -- Usage: ApparelShop.Init(chaType);
- ApparelShop.Init = function(req)
- local page, count, total = 2, 0, 0
- for i,v in pairs(SpecialApp) do
- total = total + 1
- end
- local pages = math.ceil(total/7) + 2
- for i,v in pairs(SpecialApp) do
- if count == 7 then
- Text(page,ApparelShop.Talk[4],JumpPage,page + 1)
- page = page + 1
- Talk(page,ApparelShop.Talk[3])
- count = 0
- end
- if(v.chaType == req or v.chaType == 0)then
- Text(page,GetItemName(i),JumpPage,pages)
- ApparelShop.BuyPage(pages,i,page)
- pages = pages + 1
- count = count + 1
- end
- end
- end
- ApparelShop.BuyPage = function(page,i,backPage)
- local SetName, Price = GetItemName(i), SpecialApp[i].Price
- local firstLine = PadStringText("Apparel Shop: "..SetName..", will cost you "..Price.."x Special Apparel Card.")
- InitTrigger()
- TriggerAction( 1, ApparelShop.SummonMob, SpecialApp[i].Monster,i)
- Talk(page,firstLine)
- Text(page,ApparelShop.Talk[5], ApparelShop.Purchase,i)
- Text(page,ApparelShop.Talk[6], MultiTrigger, GetMultiTrigger(), 1)
- Text(page,ApparelShop.Talk[7],JumpPage,backPage)
- end
- ApparelShop.Purchase = function(r,i)
- local Price, Qty = SpecialApp[i].Price, 1
- local SetName = GetItemName(i)
- if(GetChaFreeBagGridNum(r) < Qty)then
- HelpInfo(r,0,ApparelShop.Talk[8])
- return 0
- end
- local Card = CheckBagItem(r,ApparelShop.Card)
- if(Card < Price)then
- HelpInfo(r,0,ApparelShop.Talk[9])
- return 0
- end
- HelpInfo(r,0,"Apparel Shop: Enjoy your new apparel, "..GetChaDefaultName(r).."!")
- TakeItem(r, 0, ApparelShop.Card, Qty)
- GiveItem(r, 0, i, Qty, 4)
- end
- ApparelShop.SummonMob = function(r,m,s)
- if modelsummoned ~= 1 then
- local modelRole = CreateChaX(m, 38100, 59500, 0, 1900000, r)
- SetChaLifeTime( modelRole, 7200000 )
- modelsummoned = 1
- SpecialAppMob = {summoner = r, step = 1,SetName=GetItemName(s),summoned = 1,monsterrole = modelRole}
- else
- HelpInfo(r,0,ApparelShop.Talk[10])
- end
- end
- -- Put body of function in cha_timer if you don't use hooks and disable it;
- function ApparelMonsterModel(ignore,role)
- if(IsPlayer(role) == 1)then
- if(SpecialAppMob ~= nil)then
- if(SpecialAppMob.monsterrole ~= nil)then
- if(CheckMonsterDead(SpecialAppMob.monsterrole) ~= 1)then
- if(SpecialAppMob.step == 1)then
- Say(SpecialAppMob.monsterrole,""..GetChaDefaultName(SpecialAppMob.monsterrole)..": Hello "..GetChaDefaultName(SpecialAppMob.summoner).."!")
- elseif SpecialAppMob.step == 5 then
- Say(SpecialAppMob.monsterrole,""..GetChaDefaultName(SpecialAppMob.monsterrole)..": This is "..SpecialAppMob.SetName.."!")
- elseif SpecialAppMob.step == 9 then
- ChaMove(SpecialAppMob.monsterrole,38125,58625)
- elseif SpecialAppMob.step == 13 then
- ChaMove(SpecialAppMob.monsterrole,38100,59500)
- elseif SpecialAppMob.step == 17 then
- Say(SpecialAppMob.monsterrole,""..GetChaDefaultName(SpecialAppMob.monsterrole)..": Bye!")
- modelsummoned = 0
- KillCha(SpecialAppMob.monsterrole)
- end
- SpecialAppMob.step = SpecialAppMob.step + 1
- else
- SpecialAppMob = nil
- modelsummoned = 0
- end
- end
- end
- end
- end
- -- Global function, after define the table SpecialApp use this for chest usage;
- function SpecialApparel( role, Item )
- local ItemID = GetItemID(Item)
- local NocLock = KitbagLock(role, 0)
- if NocLock == LUA_FALSE then
- SystemNotice(role,"Your inventory is being binded.")
- UseItemFailed(role)
- return
- end
- local Cha_Boat = 0
- Cha_Boat = GetCtrlBoat(role)
- if Cha_Boat ~= nil then
- SystemNotice(role,"Cannot use while sailing")
- UseItemFailed (role)
- return
- end
- local Cha = TurnToCha(role)
- local ItemCanGet = GetChaFreeBagGridNum(Cha)
- local SlotNeed = 5
- if ItemCanGet < SlotNeed then
- SystemNotice(Cha,"Requires "..SlotNeed.." slots in inventory to open "..GetItemName(ItemID))
- UseItemFailed(Cha)
- return
- end
- local ItemID = GetItemID(Item)
- local item_name = GetItemName(ItemID)
- if(SpecialApp[ItemID]~= nil)then
- for i,v in pairs(SpecialApp[ItemID].Set)do
- GiveItem ( role , 0 , v , 1 , 4 )
- end
- end
- end
- -----------------------
- --New Apparel - Lance--
- -----------------------
- function npc_spc01()
- Talk( 1, ApparelShop.Talk[1] )
- Text( 1, ApparelShop.Talk[2], JumpPage, 2 )
- Talk( 2, ApparelShop.Talk[3])
- ApparelShop.Init(1)
- end
- -------------------------
- --New Apparel - Carsise--
- -------------------------
- function npc_spc02()
- Talk( 1, ApparelShop.Talk[1] )
- Text( 1, ApparelShop.Talk[2], JumpPage, 2 )
- Talk( 2, ApparelShop.Talk[3])
- ApparelShop.Init(2)
- end
- Hook:AddPostHook("custom_cha_timer",ApparelMonsterModel) -- Disable if don't use hooks;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement