Guest User

Untitled

a guest
Nov 13th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 33.05 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Custom Commands" version="1.0" author="Mattyx14" contact="martyx@otland.net" enabled="yes">
  3.  
  4.     <!-- News Command -->
  5.     <config name="news-config"><![CDATA[
  6.         added = {"add", "adicionar", "new"}
  7.         cleaned = {"clean", "limpar"}
  8.     ]]></config>
  9.  
  10.     <talkaction words="!notice;!news;/notice;/news" event="script"><![CDATA[
  11.         domodlib('news-config')
  12.  
  13.         local config = {
  14.             added = added,
  15.             cleaned = cleaned
  16.         }
  17.  
  18.         function onSay(cid, words, param, channel)
  19.             if(not checkExhausted(cid, 666, 10)) then
  20.                 return false
  21.             end
  22.  
  23.             local t = string.explode(param, ",")
  24.             if(table.isStrIn(param, config.add)) then
  25.                 if getPlayerGroupId (cid) > 3 then
  26.                     file = io.open('data/txt/notice.txt','a+')
  27.                     if(param == '') then
  28.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
  29.                         return true
  30.                     end
  31.  
  32.                     notice = file:write("\n"..getPlayerName(cid).." at " .. os.date("%d %B %Y - %X ", os.time()) .."\n"..t[2].."\n")
  33.                     file:close()
  34.  
  35.                     return true
  36.                 end
  37.             elseif(table.isStrIn(param, config.clean)) then
  38.                 if getPlayerGroupId (cid) > 3 then
  39.                     file = io.open('data/txt/notice.txt','w')
  40.                     if(param == '') then
  41.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
  42.                         return true
  43.                     end
  44.  
  45.                     notice = file:write("Server News:\n")
  46.                     file:close()
  47.  
  48.                     return true
  49.                 end
  50.  
  51.                 return false
  52.             end
  53.  
  54.             file = io.open('data/txt/notice.txt','r')
  55.             notice = file:read(-1)
  56.             doShowTextDialog(cid, 7528, notice)
  57.             file:close()
  58.  
  59.             return true
  60.         end
  61.     ]]></talkaction>
  62.  
  63.     <!-- Smiles event -->
  64.     <config name="animated-smiles-config"><![CDATA[
  65.         exhaust = 1 -- in seconds
  66.         storage = 3000 -- storage value used to save exhaustion
  67.     ]]></config>
  68.  
  69.     <talkaction words="xd, :d, ;d, =d, xp, :p, ;p, =p, :o, ;o, ;s, :s, :/, ;/, :*, ;*, =*, :>, ;>, :), ;), =), :(, ;(, =(, :[, ;[, :], ;], :@, ;@, ^^, ^.^, -.-" separator="," logged="no" hidden="yes" case-sensitive="no" event="script"><![CDATA[
  70.         domodlib('animated-smiles-config')
  71.  
  72.         local config = {
  73.             exhaustion = exhaust,
  74.             storage = storage
  75.         }
  76.  
  77.         function onSay(cid, words, param, channel)
  78.             if(channel ~= CHANNEL_DEFAULT) then
  79.                 return false
  80.             end
  81.  
  82.             if(exhaustion.check(cid, config.storage)) then -- prevent spam
  83.                 return true
  84.             end
  85.  
  86.             if(isInArray({":*", ";*", "=*"}, words)) then
  87.                 doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HEARTS)
  88.             end
  89.  
  90.             exhaustion.set(cid, config.storage, config.exhaustion)
  91.             doCreatureSay(cid, words, TALKTYPE_ORANGE_1)
  92.             return true
  93.         end
  94.     ]]></talkaction>
  95.  
  96.     <!-- ChangeGender Command -->
  97.     <description>
  98.         This mod will add new command for players - !changender.
  99.         Players will be able to change gender, cost can be configured.
  100.     </description>
  101.  
  102.     <config name="changender_config"><![CDATA[
  103.         costPremiumDays = 3
  104.     ]]></config>
  105.  
  106.     <talkaction words="!changender;/changender" event="buffer"><![CDATA[
  107.         domodlib('changender_config')
  108.         if(getPlayerSex(cid) >= 2) then
  109.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot change your gender.")
  110.             return
  111.         end
  112.  
  113.         if(getPlayerPremiumDays(cid) < config.costPremiumDays) then
  114.             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, not enough premium time - changing gender costs " .. config.costPremiumDays .. " premium days.")
  115.             doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  116.             return
  117.         end
  118.  
  119.         if(getPlayerPremiumDays(cid) < 65535) then
  120.             doPlayerAddPremiumDays(cid, -config.costPremiumDays)
  121.         end
  122.  
  123.         doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
  124.         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have changed your gender and lost " .. config.costPremiumDays .. " days of premium time.")
  125.         doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
  126.     ]]></talkaction>
  127.  
  128.     <!-- Buypremium Command -->
  129.     <config name="buypremium_config"><![CDATA[
  130.         days = 90
  131.         cost = 10000
  132.         maxDays = 360
  133.     ]]></config>
  134.  
  135.     <talkaction words="/buypremium;!buypremium;/pacc;!pacc" event="buffer"><![CDATA[
  136.         domodlib('buypremium_config')
  137.  
  138.         config = {
  139.             days = days,
  140.             cost = cost,
  141.             maxDays = maxDays
  142.         }
  143.  
  144.         if(getPlayerPremiumDays(cid) > config.maxDays) then
  145.             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not buy more than " .. config.days + config.maxDays .. " days of Premium Account.")
  146.             doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  147.             return
  148.         end
  149.  
  150.         if(not doPlayerRemoveMoney(cid, config.cost)) then
  151.             doPlayerSendCancel(cid, "You don't have enough money, " .. config.days .. " days premium account costs " .. config.cost .. " gold coins.")
  152.             doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  153.             return
  154.         end
  155.  
  156.         doPlayerAddPremiumDays(cid, config.days)
  157.         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought " .. config.days .. " days of premium account.")
  158.     ]]></talkaction>
  159.  
  160.     <!-- Command give all blessings -->
  161.     <description><![CDATA[
  162.         This modification adds two new commands: !bless and !blesscheck.
  163.         Also, action script is included (it uses unique id 32001 - can be used with items).
  164.     ]]></description>
  165.  
  166.     <config name="bless-system-config"><![CDATA[
  167.         blessSystem = {}
  168.         blessSystem.needPremium = getBooleanFromString(getConfigValue('blessingsOnlyPremium'))
  169.         blessSystem.config = {
  170.             baseCost = 2000,
  171.             levelCost = 200,
  172.             startLevel = 30,
  173.             endLevel = 120
  174.         }
  175.     ]]></config>
  176.  
  177.     <lib name="bless-system-lib"><![CDATA[
  178.         domodlib('bless-system-config')
  179.  
  180.         function blessSystem.buyAllBlessings(cid)
  181.             local price = blessSystem.config.baseCost
  182.             if(getPlayerLevel(cid) > blessSystem.config.startLevel) then
  183.                 price = (price + ((math.min(blessSystem.config.endLevel, getPlayerLevel(cid)) - blessSystem.config.startLevel) * blessSystem.config.levelCost))
  184.             end
  185.  
  186.             price = price * 5 * 1.2
  187.             if(blessSystem.needPremium and not isPremium(cid)) then
  188.                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a premium account to use blessings.")
  189.                 return false
  190.             end
  191.  
  192.             for i = 1, 5 do
  193.                 if(getPlayerBlessing(cid, i)) then
  194.                     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have all blessings.")
  195.                     return false
  196.                 end
  197.             end
  198.  
  199.             if(not doPlayerRemoveMoney(cid, price)) then
  200.                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have enough money for blessings. (You need " .. price .. " gp's)")
  201.                 return false
  202.             end
  203.  
  204.             for i = 1, 5 do
  205.                 doPlayerAddBlessing(cid, i)
  206.             end
  207.  
  208.             doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have been blessed by the gods!")
  209.             doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
  210.             return true
  211.         end
  212.     ]]></lib>
  213.  
  214.     <talkaction words="!blesscheck;!blesstest" event="script"><![CDATA[
  215.         domodlib('bless-system-config')
  216.  
  217.         local BLESSINGS = {"Wisdom of Solitude", "Spark of the Phoenix", "Fire of the Suns", "Spiritual Shielding", "Embrace of Tibia"}
  218.         function onSay(cid, words, param)
  219.             local result = ""
  220.             for i = 1, (table.maxn(BLESSINGS) - 1) do
  221.                 result = (getPlayerBlessing(cid, i) and result .. (result:len() > 0 and ", " or "") .. BLESSINGS[i] or result)
  222.             end
  223.  
  224.             return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result:len() > 0 and "Currently you have the following blessings: " .. result .. "." or "You do not have any blessing.")
  225.         end
  226.     ]]></talkaction>
  227.  
  228.     <talkaction words="!bless;/bless" event="script"><![CDATA[
  229.         domodlib('bless-system-config')
  230.         domodlib('bless-system-lib')
  231.  
  232.         function onSay(cid, words, param, channel)
  233.             blessSystem.buyAllBlessings(cid)
  234.             return true
  235.         end
  236.     ]]></talkaction>
  237.  
  238.     <action uniqueid="32001" event="script"><![CDATA[
  239.         domodlib('bless-system-config')
  240.         domodlib('bless-system-lib')
  241.  
  242.         function onUse(cid, item, fromPosition, itemEx, toPosition)
  243.             blessSystem.buyAllBlessings(cid)
  244.             return true
  245.         end
  246.     ]]></action>
  247.  
  248.     <!-- Refill Boots Command -->
  249.     <description>
  250.         This mod adds a new command to the server, that can be used to refill (more precisely: change one id to another id
  251.             for fixed price). More items can be added by modifying 'items' table.
  252.     </description>
  253.  
  254.     <config name="command-refill-config"><![CDATA[
  255.         items = {
  256.             ["soft"] = { -- soft boots
  257.                 id = 10021,
  258.                 new_id = 2640,
  259.                 price = 10000,
  260.                 message = "Soft boots has been refilled."
  261.             },
  262.  
  263.             ["firewalker"] = { -- firewalker boots
  264.                 id = 10022,
  265.                 new_id = 9932,
  266.                 price = 50000,
  267.                 message = "Firewalker boots has been refilled."
  268.             }
  269.         }
  270.     ]]></config>
  271.  
  272.     <lib name="command-refill-lib"><![CDATA[
  273.         domodlib('command-refill-config')
  274.  
  275.         command_refill = {
  276.             items = items,
  277.  
  278.             buy = function (cid, name)
  279.                 local item = command_refill.items[name]
  280.                 if(not item) then
  281.                     print('custom-commands.xml - invalid item name used (' .. name .. ')')
  282.                     return false
  283.                 end
  284.  
  285.                 if(getPlayerItemCount(cid, item.id) >= 1) then
  286.                     if(getPlayerMoney(cid) >= item.price) then
  287.                         if(doPlayerRemoveItem(cid, item.id, 1)) then
  288.                             doPlayerBuyItem(cid, item.new_id, 1, item.price, 1)
  289.                             if(item.message) then
  290.                                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, item.message)
  291.                             end
  292.                             return true
  293.                         end
  294.                     else
  295.                         doPlayerSendCancel(cid, "Not enough money.")
  296.                     end
  297.                 else
  298.                     doPlayerSendCancel(cid, "Item not found in your inventory.")
  299.                 end
  300.  
  301.                 return false
  302.             end
  303.         }
  304.     ]]></lib>
  305.  
  306.     <talkaction words="!refill" event="script"><![CDATA[
  307.         domodlib('command-points-lib')
  308.  
  309.         function onSay(cid, words, param, channel)
  310.             param = param:lower():trim()
  311.             if(param == '') then
  312.                 local str = ""
  313.                 for name, item in pairs(command_refill.items) do
  314.                     str = str .. "!" .. name .. "\n"
  315.                 end
  316.  
  317.                 doPlayerPopupFYI(cid, str)
  318.                 return true
  319.             end
  320.  
  321.             local item = command_refill.items[param]
  322.             if(not item) then
  323.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid option.")
  324.                 return true
  325.             end
  326.  
  327.             command_refill.buy(cid, item.name)
  328.             return true
  329.         end
  330.     ]]></talkaction>
  331.  
  332.     <talkaction words="!soft" event="script"><![CDATA[
  333.         domodlib('command-refill-lib')
  334.         function onSay(cid, words, param, channel)
  335.             command_refill.buy(cid, "soft")
  336.             return true
  337.         end
  338.     ]]></talkaction>
  339.  
  340.     <talkaction words="!firewalker" event="script"><![CDATA[
  341.         domodlib('command-refill-lib')
  342.         function onSay(cid, words, param, channel)
  343.             command_refill.buy(cid, "firewalker")
  344.             return true
  345.         end
  346.     ]]></talkaction>
  347.  
  348.     <!-- Promotion(npc) command -->
  349.     <config name="command-promotion-config"><![CDATA[
  350.         -- how much gold coins does it cost
  351.         cost = 20000
  352.  
  353.         -- required level to buy a promotion
  354.         minLevel = 20
  355.  
  356.         -- need premium account to use command?
  357.         needPremium = "yes"
  358.  
  359.         -- maximum promotion level player can advance to (default = 1). Can be ignored if there are not any new vocations on the server.
  360.         maxPromotionLevel = 1
  361.     ]]></config>
  362.  
  363.     <talkaction words="!promotion" event="script"><![CDATA[
  364.         domodlib('command-promotion-config')
  365.  
  366.         local config = {
  367.             cost = cost,
  368.             minLevel = minLevel,
  369.             needPremium = needPremium,
  370.             maxPromotionLevel = maxPromotionLevel
  371.         }
  372.  
  373.         config.needPremium = getBooleanFromString(config.needPremium)
  374.  
  375.         function onSay(cid, words, param, channel)
  376.             if(config.needPremium and not isPremium(cid)) then
  377.                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a premium account to get promotion.")
  378.                 return true
  379.             end
  380.  
  381.             if(getPlayerPromotionLevel(cid) >= config.maxPromotionLevel) then
  382.                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are already promoted.")
  383.             elseif(getPlayerLevel(cid) < config.minLevel) then
  384.                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. config.minLevel .. " to get promotion.")
  385.             elseif(doPlayerRemoveMoney(cid, config.cost) ~= TRUE) then
  386.                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have enought money! (Promotion cost " .. config.cost .. " gold coins.")
  387.             else
  388.                 setPlayerPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
  389.                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
  390.             end
  391.  
  392.             return true
  393.         end
  394.     ]]></talkaction>
  395.  
  396.     <!-- Me Player Save Command -->
  397.     <config name="command-save-config"><![CDATA[
  398.         exhaust = 3 -- in minutes
  399.         storage = 3003 -- storage value used to save exhaustion
  400.     ]]></config>
  401.  
  402.     <talkaction words="!saveme;/saveme" event="script"><![CDATA[
  403.         domodlib('command-save-config')
  404.  
  405.         local config = {
  406.             exhaust = exhaust,
  407.             storage = storage
  408.         }
  409.  
  410.         function onSay(cid, words, param, channel)
  411.             if(exhaust.check(cid, config.storage)) then
  412.                 doPlayerSendCancel(cid, "You can save yourself only once per " .. config.exhaust .. " minutes.")
  413.                 return true
  414.             end
  415.  
  416.             if(doPlayerSave(cid)) then
  417.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your character has been succesfully saved.")
  418.                 exhaust.set(cid, config.storage, config.exhaust * 60)
  419.             else
  420.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Error while saving your character. Please try again later.")
  421.             end
  422.  
  423.             return true
  424.         end
  425.     ]]></talkaction>
  426.  
  427.     <!-- Guild Cast Command -->
  428.     <config name="guild-cast-config"><![CDATA[
  429.         exhaust = 10 -- in seconds
  430.         storage = 3001 -- storage value used to save exhaustion
  431.         storageColor = 3002 -- storage value used to save previously used message color
  432.     ]]></config>
  433.  
  434.     <talkaction words="!gc;/gc" event="script"><![CDATA[
  435.         domodlib('guild-cast-config')
  436.  
  437.         local config = {
  438.             exhaustion = exhaust,
  439.             storage = storage,
  440.             storageColor = storageColor
  441.         }
  442.  
  443.         function onSay(cid, words, param, channel)
  444.             if(exhaustion.check(cid, config.storage)) then
  445.                 doPlayerSendCancel(cid, "You can broadcast message only one time per " .. config.exhaustion .. " seconds.")
  446.                 return true
  447.             end
  448.  
  449.             if(param == '') then
  450.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to type a message to broadcast!")
  451.                 return true
  452.             end
  453.  
  454.             local playerGuild = getPlayerGuildId(cid)
  455.             if(playerGuild == false) then
  456.                 doPlayerSendCancel(cid, "Sorry, you're not in a guild.");
  457.                 return true
  458.             end
  459.  
  460.             if(getPlayerGuildLevel(cid) < GUILDLEVEL_VICE) then
  461.                 doPlayerSendCancel(cid, "You have to be at least Vice-Leader to guildcast!")
  462.                 return true
  463.             end
  464.  
  465.             local messageType = MESSAGE_STATUS_WARNING
  466.             local t = string.explode(param, ";")
  467.             if(not t[2]) then
  468.                 if(getPlayerStorageValue(cid, config.storageColor) ~= -1) then
  469.                     messageType = getPlayerStorageValue(cid, config.storageColor)
  470.                 end
  471.             else
  472.                 if(MESSAGE_TYPES[t[1]] ~= nil) then
  473.                     messageType = MESSAGE_TYPES[t[1]]
  474.                 end
  475.                 param = t[2]
  476.             end
  477.  
  478.             if(messageType < MESSAGE_FIRST or messageType > MESSAGE_LAST) then
  479.                 messageType = MESSAGE_STATUS_WARNING
  480.                 --setPlayerStorageValue(cid, MESSAGE_STATUS_WARNING, messageType)
  481.                 --doPlayerSendCancel(cid, "Unknown message type.")
  482.                 --return true
  483.             end
  484.  
  485.             local players = getPlayersOnline()
  486.             local message = "*Guild* " .. getCreatureName(cid) .. " [" .. getPlayerLevel(cid) .. "]:\n" .. param
  487.             local members = 0
  488.             for i, tid in ipairs(players) do
  489.                 if(getPlayerGuildId(tid) == playerGuild) then
  490.                     doPlayerSendTextMessage(tid, messageType, message)
  491.                     members = members + 1
  492.                 end
  493.             end
  494.  
  495.             setPlayerStorageValue(cid, config.storageColor, messageType)
  496.             exhaustion.set(cid, config.storage, config.exhaustion)
  497.             doPlayerSendCancel(cid, "Message sent to your guild members. (Total: " .. members .. ")")
  498.             return true
  499.         end
  500.     ]]></talkaction>
  501.  
  502.     <!-- Guild Outfit Command -->
  503.     <config name="guild-outfit-config"><![CDATA[
  504.         exhaust = 30 -- in seconds
  505.         storage = 3005 -- storage value used to save exhaustion
  506.     ]]></config>
  507.  
  508.     <talkaction words="!go;/go" event="script"><![CDATA[
  509.         domodlib('guild-outfit-config')
  510.  
  511.         local config = {
  512.             exhaust = exhaust,
  513.             storage = storage
  514.         }
  515.  
  516.         function onSay(cid, words, param, channel)
  517.             if(exhaust.check(cid, config.storage)) then
  518.                 doPlayerSendCancel(cid, "You can change outfit only 1 time per " .. config.exhaust .. " seconds.")
  519.                 return true
  520.             end
  521.  
  522.             local playerGuild = getPlayerGuildId(cid)
  523.             if(not playerGuild or playerGuild == 0) then
  524.                 doPlayerSendCancel(cid, "Sorry, you're not in a guild.")
  525.                 return true
  526.             end
  527.  
  528.             if(getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
  529.                 doPlayerSendCancel(cid, "You have to be Leader of your guild to change outfits!")
  530.                 return true
  531.             end
  532.  
  533.             local outfit, members = getCreatureOutfit(cid), 0
  534.             local message = "*Guild* Your outfit has been changed by leader. (" .. getCreatureName(cid) .. ")"
  535.             for _, tid in ipairs(getPlayersOnline()) do
  536.                 if(getPlayerGuildId(tid) == playerGuild and cid ~= tid) then
  537.                     local newOutfit = outfit
  538.                     if(not canPlayerWearOutfit(tid, outfit.lookType, outfit.lookAddons)) then
  539.                         local tmpOutfit = getCreatureOutfit(tid)
  540.                         newOutfit.lookAddons = 0--tmpOutfit.lookAddons
  541.                         if(not canPlayerWearOutfit(tid, outfit.lookType, 0)) then
  542.                             newOutfit.lookType = tmpOutfit.lookType
  543.                         end
  544.                     end
  545.  
  546.                     doSendMagicEffect(getCreaturePosition(tid), 66)
  547.                     doCreatureChangeOutfit(tid, newOutfit)
  548.                     doPlayerSendTextMessage(tid, MESSAGE_INFO_DESCR, message)
  549.                     members = members + 1
  550.                 end
  551.             end
  552.  
  553.             exhaust.set(cid, config.storage, config.exhaust)
  554.             doPlayerSendCancel(cid, "Guild members outfit has been changed. (Total: " .. members .. ")")
  555.             return true
  556.         end
  557.     ]]></talkaction>
  558.  
  559.     <!-- Buy Command -->
  560.     <config name="command-buy-config"><![CDATA[
  561.         items = {
  562.             ['brown backpack'] = {cost = 500, id = 1988},
  563.             ['green backpack'] = {cost = 500, id = 1998},
  564.             ['yellow backpack'] = {cost = 500, id = 1999},
  565.             ['red backpack'] = {cost = 500, id = 2000},
  566.             ['purple backpack'] = {cost = 500, id = 2001},
  567.             ['grey backpack'] = {cost = 500, id = 2003},
  568.             ['blue backpack'] = {cost = 500, id = 2002},
  569.             ['gold backpack'] = {cost = 500, id = 2004},
  570.             ['amulet of loss'] = {cost = 300000, id = 2173},
  571.             ['rope'] = {cost = 500, id = 2120},
  572.             ['shovel'] = {cost = 500, id = 2554},
  573.             ['machete'] = {cost = 500, id = 2420},
  574.             ['fishing rod'] = {cost = 500, id = 2580}
  575.         }
  576.     ]]></config>
  577.     <talkaction words="!buy;/buy" event="script"><![CDATA[
  578.         domodlib('command-buy-config')
  579.         local config = {
  580.             items = items
  581.         }
  582.  
  583.         function onSay(cid, words, param, channel)
  584.             if(param == '') then
  585.                 local str = ""
  586.                 for name, options in pairs(config.items) do
  587.                     str = str .. "\n" .. name
  588.                 end
  589.  
  590.                 doPlayerPopupFYI(cid, "/buy or !buy:\n\n" .. str)
  591.                 return true
  592.             end
  593.  
  594.             local item = config.items[param]
  595.             if(item ~= nil) then
  596.                 if(not doPlayerRemoveMoney(cid, item.cost)) then
  597.                     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Not enough money to buy " .. param .. ".\n(" .. item.cost .. "gp)")
  598.                     return true
  599.                 end
  600.  
  601.                 local amount = item.amount and item.amount or 1
  602.                 doPlayerAddItem(cid, item.id, amount)
  603.                 doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
  604.             else
  605.                 doPlayerSendCancel(cid, "Item not found. Use '!buy' to see the list.")
  606.             end
  607.  
  608.             return true
  609.         end
  610.     ]]></talkaction>
  611.  
  612.     <!-- Send animated text -->
  613.     <talkaction words="!me;/me" event="buffer" value="doCreatureSay(cid, getCreatureName(cid) .. ' ' .. param, TALKTYPE_MONSTER)"/>
  614.  
  615.     <!-- Check Player Spells -->
  616.     <talkaction words="!spells;/spells" event="script"><![CDATA[
  617.         function onSay(cid, words, param)
  618.             local t = {}
  619.             for i = 0, getPlayerInstantSpellCount(cid) - 1 do
  620.                 local spell = getPlayerInstantSpellInfo(cid, i)
  621.                 if(spell.level ~= 0) then
  622.                     if(spell.manapercent > 0) then
  623.                         spell.mana = spell.manapercent .. "%"
  624.                     end
  625.  
  626.                     table.insert(t, spell)
  627.                 end
  628.             end
  629.  
  630.             table.sort(t, function(a, b) return a.level < b.level end)
  631.             local text, prevLevel = "", -1
  632.             for i, spell in ipairs(t) do
  633.                 local line = ""
  634.                 if(prevLevel ~= spell.level) then
  635.                     if(i ~= 1) then
  636.                         line = "\n"
  637.                     end
  638.  
  639.                     line = line .. "Spells for Level " .. spell.level .. "\n"
  640.                     prevLevel = spell.level
  641.                 end
  642.  
  643.                 text = text .. line .. "  " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
  644.             end
  645.  
  646.             doShowTextDialog(cid, 2175, text)
  647.             return true
  648.         end
  649.     ]]></talkaction>
  650.  
  651.     <!-- Check Members Guild inGame -->
  652.     <talkaction words="!guildmeb;/guildmeb" event="script"><![CDATA[
  653.         function onSay(cid, words, param, channel)
  654.             if param == '' then
  655.                 local list = db.getResult("SELECT `name` FROM `guilds`;")
  656.                     if(list:getID() ~= -1) then
  657.                 local v = ''
  658.                 repeat
  659.                     v = v .. list:getDataString("name")  .. "\n"
  660.                 until not list:next()
  661.                     list:free()
  662.                     doShowTextDialog(cid, 2529, v)
  663.             else
  664.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no guilds on this server.")
  665.             end
  666.         else
  667.  
  668.         local id = getGuildId(param)
  669.             if id then
  670.                 local list = db.getResult("SELECT `name`, `rank_id` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = " .. id .. ");")
  671.                     if(list:getID() ~= -1) then
  672.                     local v = ''
  673.                         repeat
  674.                             local rank = db.getResult("SELECT `name` FROM `guild_ranks` WHERE `id` = " .. list:getDataInt("rank_id") .. " LIMIT 1;")
  675.                                 v = v .. list:getDataString("name")  .. " [" .. rank:getDataString("name") .. "]\n"
  676.                                 rank:free()
  677.                         until not list:next()
  678.                                 list:free()
  679.                                 doShowTextDialog(cid, 2529, v)
  680.                         else
  681.                             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no players in this guild.")
  682.                         end
  683.                     else
  684.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This guild doesn't exist.")
  685.                     end
  686.                 end
  687.             return true
  688.         end
  689.     ]]></talkaction>
  690.  
  691.     <!-- Full Stamina Command at player -->
  692.     <talkaction words="!stamina;/stamina" event="script"><![CDATA[
  693.         function onSay(cid, words, param)
  694.             if getPlayerMoney(cid) >= 250000 then
  695.                 doPlayerRemoveMoney(cid, 250000)
  696.                 doPlayerSetStamina(cid, 2520)
  697.             else
  698.                 doPlayerSendCancel(cid, "Nesesitas 25 crystal coins para llenarte la stamina.")
  699.             end
  700.  
  701.             return true
  702.         end
  703.     ]]></talkaction>
  704.  
  705.     <!-- Info mana - exp -->
  706.     <talkaction words="!mana" event="script"><![CDATA[
  707.          function onSay(cid, words, param, channel)
  708.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to spent " .. (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, TRUE) + 1) - getPlayerSpentMana(cid))  ..
  709.                 " mana to next magic level.")
  710.             return true
  711.         end
  712.     ]]></talkaction>
  713.  
  714.     <talkaction words="!exp" event="script"><![CDATA[
  715.         function onSay(cid, words, param, channel)
  716.             local expinfo = getPlayerExperience(cid)
  717.             if (words == "!exp") then
  718.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. expinfo.. " experience points to next level")
  719.             end
  720.  
  721.             return true
  722.         end
  723.     ]]></talkaction>
  724.  
  725.     <!-- GiveReward Item to player -->
  726.     <talkaction words="/giveitem" group="4" access="3" event="script" log="yes"><![CDATA[
  727.         function onSay(cid, words, param, channel)
  728.             if(param == '') then
  729.                 return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
  730.             end
  731.  
  732.             local t = string.explode(param, ",")
  733.             local id = tonumber(t[1])
  734.             if not id then
  735.                 id = getItemIdByName(t[1], false)
  736.                 if not id then
  737.                     return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item with such name does not exist.")
  738.                 end
  739.             end
  740.  
  741.             t[2] = tonumber(t[2])
  742.             local amount = t[2] or 1
  743.  
  744.             for _, pid in ipairs(getPlayersOnline()) do
  745.                 doDecayItem(doPlayerAddItem(pid, id, amount))
  746.             end
  747.  
  748.             return true
  749.         end
  750.     ]]></talkaction>
  751.  
  752.     <!-- GiveReward Item to player -->
  753.     <talkaction words="!giveitem" group="4" access="3" event="script" log="yes"><![CDATA[
  754.         function onSay(cid, words, param, channel)
  755.         local param = string.explode(param, ",")
  756.  
  757.         local item = {
  758.             player = getPlayerByNameWildcard(param[1]),
  759.             itemid = tonumber(param[2]),
  760.             type = tonumber(param[3]),
  761.             charges = 1
  762.         }
  763.  
  764.         local str = {
  765.             "",
  766.             ""
  767.         }
  768.  
  769.             if(item.player == 0 or item.player == nil) then
  770.                 doPlayerSendCancel(cid, "Player " .. param[1] .. " is not online.")
  771.                 doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  772.                 return true
  773.             end
  774.  
  775.             if(not item.itemid) then
  776.                 item.itemid = getItemIdByName(param[2], true)
  777.                 if not item.itemid then
  778.                     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
  779.                     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  780.                     return true
  781.                 end
  782.             end
  783.  
  784.             if(item.itemid < 1) then
  785.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No item specified.")
  786.                 doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  787.                 return true
  788.             end
  789.  
  790.             if(not item.type) then
  791.                 if(isItemRune(item.itemid) or isItemStackable(item.itemid)) == true then
  792.                     item.type = 100
  793.                     item.charges = 1
  794.                 else
  795.                     item.type = 1
  796.                     item.charges = 1
  797.                 end
  798.             end
  799.  
  800.             if(isItemMovable(item.itemid) == true) then
  801.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give that item.")
  802.                 doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  803.                 return true
  804.             end
  805.  
  806.         local str = {
  807.             "You give " .. item.type .."x " .. getItemNameById(item.itemid) .. " to " .. param[1] .. ".",
  808.             "You received " .. item.type .. "x " .. getItemNameById(item.itemid) .. " from " .. getCreatureName(cid) .. "."
  809.         }
  810.  
  811.             if(isItemRune(item.itemid) == true) then
  812.                 item.charges = item.type
  813.                 item.type = 1
  814.                 str[1] = "You give " .. item.type .. "x " .. getItemNameById(item.itemid) .. " with " .. item.charges .. "x charges to " .. param[1] .. "."
  815.                 str[2] = "You received " .. item.type .. "x " .. getItemNameById(item.itemid) .. " with " .. item.charges .. " charges from " .. getCreatureName(cid) .. "."
  816.             end
  817.  
  818.             doPlayerGiveItem(item.player, item.itemid, item.type, item.charges)
  819.             doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
  820.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str[1])
  821.             doSendMagicEffect(getCreaturePosition(item.player), CONST_ME_MAGIC_RED)
  822.             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str[2])
  823.             return true
  824.         end
  825.     ]]></talkaction>
  826.  
  827.     <!-- Bank Command -->
  828.     <config name="command-bank-config"><![CDATA[
  829.         transferDisabledVocations = {0} -- disable non vocation characters
  830.     ]]></config>
  831.  
  832.     <talkaction words="!bank;/bank" event="script"><![CDATA[
  833.         domodlib('command-bank-config')
  834.         local config = {
  835.             transferDisabledVocations = transferDisabledVocations
  836.         }
  837.  
  838.         local function validAmount(amount)
  839.             return (isNumber(amount) and amount > 0 and amount < 4294967296)
  840.         end
  841.         local function getAmount(amount, cid, f)
  842.             return (amount == 'all' and f(cid) or tonumber(amount))
  843.         end
  844.         local function getPlayerVocationByName(name)
  845.             local result = db.getResult("SELECT `vocation` FROM `players` WHERE `name` = " .. db.escapeString(name))
  846.             if(result:getID() == -1) then
  847.                 return false
  848.             end
  849.  
  850.             local value = result:getDataString("vocation")
  851.             result:free()
  852.             return value
  853.         end
  854.  
  855.         function onSay(cid, words, param, channel)
  856.             if(param == '') then
  857.                 doPlayerPopupFYI(cid,
  858.                     "Bank management manual.\n\n" ..
  859.                     "!bank or /bank balance - show your account balance\n" ..
  860.                     "!bank or /bank deposit 100 - deposit 100 gold\n" ..
  861.                     "!bank or /bank withdraw 50 - withdraw 50 gold\n" ..
  862.                     "!bank or /bank transfer 30 God - transfer 30 gold to player God\n\n" ..
  863.                     "Tip: you can also use 'all' as amount.\n" ..
  864.                     "!bank or /bank deposit all - deposit all gold you have\n" ..
  865.                     "!bank or /bank withdraw all - withdraw all gold from your bank account"
  866.                 )
  867.                 return true
  868.             end
  869.  
  870.             local t = string.explode(param, " ", 2)
  871.             local command = t[1]:lower()
  872.             if(command == 'balance') then
  873.                 doPlayerSendCancel(cid, "Your account balance is " .. getPlayerBalance(cid) .. " gold.")
  874.             elseif(command == 'deposit') then
  875.                 if(not t[2]) then
  876.                     doPlayerSendCancel(cid, "Amount is required.")
  877.                     return true
  878.                 end
  879.  
  880.                 local amount = getAmount(t[2], cid, getPlayerMoney)
  881.                 if(validAmount(amount) and getPlayerMoney(cid) >= amount and doPlayerDepositMoney(cid, amount)) then
  882.                     doPlayerSendCancel(cid, amount .. " gold has been deposited.")
  883.                 else
  884.                     doPlayerSendCancel(cid, "Not enough money to deposit.")
  885.                 end
  886.             elseif(command == 'withdraw') then
  887.                 if(not t[2]) then
  888.                     doPlayerSendCancel(cid, "Amount is required.")
  889.                     return true
  890.                 end
  891.  
  892.                 local amount = getAmount(t[2], cid, getPlayerBalance)
  893.                 if(validAmount(amount) and getPlayerBalance(cid) >= amount and doPlayerWithdrawMoney(cid, amount)) then
  894.                     doPlayerSendCancel(cid, amount .. " gold has been withdrawn.")
  895.                 else
  896.                     doPlayerSendCancel(cid, "Not enough money to withdraw.")
  897.                 end
  898.             elseif(command == 'transfer') then
  899.                 if(not t[2]) then
  900.                     doPlayerSendCancel(cid, "Amount is required.")
  901.                     return true
  902.                 end
  903.  
  904.                 if(not t[3]) then
  905.                     doPlayerSendCancel(cid, "Player name to transfer is required.")
  906.                     return true
  907.                 end
  908.  
  909.                 local amount, target = tonumber(t[2]), t[3]
  910.                 if(getPlayerGUID(cid) == getPlayerGUIDByName(target)) then
  911.                     doPlayerSendCancel(cid, "You cannot transfer money to yourself.")
  912.                 elseif(isInArray(config.transferDisabledVocations, getPlayerVocation(cid))) then
  913.                     doPlayerSendCancel(cid, "Your vocation cannot transfer money.")
  914.                 elseif(not validAmount(amount) or getPlayerBalance(cid) < amount) then
  915.                     doPlayerSendCancel(cid, "Not enough money to transfer.")
  916.                 else
  917.                     local targetVocation = getPlayerVocationByName(target)
  918.                     if(not playerExists(target) or not targetVocation or isInArray(config.transferDisabledVocations, targetVocation) or not doPlayerTransferMoneyTo(cid, target, amount)) then
  919.                         doPlayerSendCancel(cid, "This player does not exist on this world or have no vocation.")
  920.                     else
  921.                         doPlayerSendCancel(cid, "You have transferred " .. amount .. " gold to \"" .. target .."\".")
  922.                     end
  923.                 end
  924.             else
  925.                 doPlayerSendCancel(cid, "Invalid command usage. Use '!bank' to view manual.")
  926.             end
  927.  
  928.             return true
  929.         end
  930.     ]]></talkaction>
  931.  
  932.     <!-- Rename Command -->
  933.     <config name="rename-config"><![CDATA[
  934.         blacklistParam = {"account manager", "god", "cm", "gm", "tutor", "tester"}
  935.         maxTextLenght = 15
  936.         minWordLenght = 3
  937.         delay = 2
  938.         item = {
  939.             Id = 1111, count = 0
  940.         }
  941.     ]]></config>
  942.  
  943.     <talkaction words="!changename;/changename;!namechange;/namechange" event="script"><![CDATA[
  944.         domodlib('rename-config')
  945.  
  946.         local config = {
  947.             blacklistParam = blacklistParam,
  948.             maxTextLenght = maxTextLenght,
  949.             minWordLenght = minWordLenght,
  950.             delay = delay,
  951.             item = item
  952.         }
  953.  
  954.         function onSay(cid, words, param, channel)
  955.             local textCancel, t = config.text, string.explode(param, ",")
  956.             if(param == '') then
  957.                 return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
  958.             elseif((getPlayerGUIDByName(t[1]) ~= nil) and (not getBooleanFromString(t[2]))) then
  959.                 textCancel = "That name is already in use."
  960.             elseif(getPlayerItemCount(cid, config.item.Id) < config.item.count) then
  961.                 textCancel = "You do not fulfill the requirements."
  962.             elseif(not getTilePzInfo(getCreaturePosition(cid))) then
  963.                 textCancel = "You must be inside a protection zone to use this command."
  964.             elseif(string.len(tostring(t[1])) >= config.maxTextLenght) then
  965.                 textCancel = "You can only use a maximum of " .. config.maxTextLenght .. " characters."
  966.             elseif(string.find(t[1]:lower(), "[^%l%s]") ~= nil) then
  967.                 textCancel = "You cannot use symbols."
  968.             else
  969.                 for blacklist = 1, table.maxn(config.blacklistParam) do
  970.                     if(string.find(t[1]:lower(), config.blacklistParam[blacklist]) ~= nil) then
  971.                         textCancel = "Invalid name entry."
  972.                         break
  973.                     end
  974.                 end
  975.             end
  976.  
  977.             if(config.text ~= textCancel) then
  978.                 doPlayerSendCancel(cid, textCancel)
  979.                 return true
  980.             end
  981.  
  982.             local paramTemp, space, oldName = '', '', getCreatureName(cid)
  983.             for word in string.gmatch(t[1], "%a+") do
  984.                 if(string.len(word) < config.minWordLenght) then
  985.                     doPlayerSendCancel(cid, "Each word must have a minimum of " .. config.minWordLenght .. " characters.")
  986.                     return true
  987.                 end
  988.  
  989.                 paramTemp = "" .. paramTemp .. "" .. space .. "" .. word .. ""
  990.                 if(space == '') then
  991.                     space = " "
  992.                 end
  993.             end
  994.  
  995.             local guid = getPlayerGUID(cid)
  996.             t[1] = paramTemp
  997.             doPlayerRemoveItem(cid, config.item.Id, config.item.count)
  998.             if(pcall(doPlayerChangeName, guid, oldName, t[1]) == false) then
  999.                 db.executeQuery("INSERT INTO `player_namelocks` (`player_id`, `name`, `new_name`, `date`) VALUES (" .. guid .. ", " .. db.escapeString(oldName) .. ", " .. db.escapeString(t[1]) .. ", " .. os.time() .. ");")
  1000.                 db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(t[1]) .. " WHERE `id` = " .. guid .. " LIMIT 1;")
  1001.             end
  1002.  
  1003.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your name has been changed successfully. You will be kicked in " .. config.delay .. " seconds.")
  1004.             addEvent(function(cid, forceLogout)
  1005.                 if(isPlayer(cid)) then
  1006.                     doRemoveCreature(cid, forceLogout)
  1007.                 end
  1008.             end, config.delay * 1000, cid, false)
  1009.  
  1010.             return true
  1011.         end
  1012.     ]]></talkaction>
  1013.    
  1014. </mod>
Add Comment
Please, Sign In to add comment