Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <mod name="Custom Commands" version="1.0" author="Mattyx14" contact="martyx@otland.net" enabled="yes">
- <!-- News Command -->
- <config name="news-config"><![CDATA[
- added = {"add", "adicionar", "new"}
- cleaned = {"clean", "limpar"}
- ]]></config>
- <talkaction words="!notice;!news;/notice;/news" event="script"><![CDATA[
- domodlib('news-config')
- local config = {
- added = added,
- cleaned = cleaned
- }
- function onSay(cid, words, param, channel)
- if(not checkExhausted(cid, 666, 10)) then
- return false
- end
- local t = string.explode(param, ",")
- if(table.isStrIn(param, config.add)) then
- if getPlayerGroupId (cid) > 3 then
- file = io.open('data/txt/notice.txt','a+')
- if(param == '') then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
- return true
- end
- notice = file:write("\n"..getPlayerName(cid).." at " .. os.date("%d %B %Y - %X ", os.time()) .."\n"..t[2].."\n")
- file:close()
- return true
- end
- elseif(table.isStrIn(param, config.clean)) then
- if getPlayerGroupId (cid) > 3 then
- file = io.open('data/txt/notice.txt','w')
- if(param == '') then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
- return true
- end
- notice = file:write("Server News:\n")
- file:close()
- return true
- end
- return false
- end
- file = io.open('data/txt/notice.txt','r')
- notice = file:read(-1)
- doShowTextDialog(cid, 7528, notice)
- file:close()
- return true
- end
- ]]></talkaction>
- <!-- Smiles event -->
- <config name="animated-smiles-config"><![CDATA[
- exhaust = 1 -- in seconds
- storage = 3000 -- storage value used to save exhaustion
- ]]></config>
- <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[
- domodlib('animated-smiles-config')
- local config = {
- exhaustion = exhaust,
- storage = storage
- }
- function onSay(cid, words, param, channel)
- if(channel ~= CHANNEL_DEFAULT) then
- return false
- end
- if(exhaustion.check(cid, config.storage)) then -- prevent spam
- return true
- end
- if(isInArray({":*", ";*", "=*"}, words)) then
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HEARTS)
- end
- exhaustion.set(cid, config.storage, config.exhaustion)
- doCreatureSay(cid, words, TALKTYPE_ORANGE_1)
- return true
- end
- ]]></talkaction>
- <!-- ChangeGender Command -->
- <description>
- This mod will add new command for players - !changender.
- Players will be able to change gender, cost can be configured.
- </description>
- <config name="changender_config"><![CDATA[
- costPremiumDays = 3
- ]]></config>
- <talkaction words="!changender;/changender" event="buffer"><![CDATA[
- domodlib('changender_config')
- if(getPlayerSex(cid) >= 2) then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot change your gender.")
- return
- end
- if(getPlayerPremiumDays(cid) < config.costPremiumDays) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, not enough premium time - changing gender costs " .. config.costPremiumDays .. " premium days.")
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
- return
- end
- if(getPlayerPremiumDays(cid) < 65535) then
- doPlayerAddPremiumDays(cid, -config.costPremiumDays)
- end
- doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have changed your gender and lost " .. config.costPremiumDays .. " days of premium time.")
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
- ]]></talkaction>
- <!-- Buypremium Command -->
- <config name="buypremium_config"><![CDATA[
- days = 90
- cost = 10000
- maxDays = 360
- ]]></config>
- <talkaction words="/buypremium;!buypremium;/pacc;!pacc" event="buffer"><![CDATA[
- domodlib('buypremium_config')
- config = {
- days = days,
- cost = cost,
- maxDays = maxDays
- }
- if(getPlayerPremiumDays(cid) > config.maxDays) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not buy more than " .. config.days + config.maxDays .. " days of Premium Account.")
- doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
- return
- end
- if(not doPlayerRemoveMoney(cid, config.cost)) then
- doPlayerSendCancel(cid, "You don't have enough money, " .. config.days .. " days premium account costs " .. config.cost .. " gold coins.")
- doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
- return
- end
- doPlayerAddPremiumDays(cid, config.days)
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought " .. config.days .. " days of premium account.")
- ]]></talkaction>
- <!-- Command give all blessings -->
- <description><![CDATA[
- This modification adds two new commands: !bless and !blesscheck.
- Also, action script is included (it uses unique id 32001 - can be used with items).
- ]]></description>
- <config name="bless-system-config"><![CDATA[
- blessSystem = {}
- blessSystem.needPremium = getBooleanFromString(getConfigValue('blessingsOnlyPremium'))
- blessSystem.config = {
- baseCost = 2000,
- levelCost = 200,
- startLevel = 30,
- endLevel = 120
- }
- ]]></config>
- <lib name="bless-system-lib"><![CDATA[
- domodlib('bless-system-config')
- function blessSystem.buyAllBlessings(cid)
- local price = blessSystem.config.baseCost
- if(getPlayerLevel(cid) > blessSystem.config.startLevel) then
- price = (price + ((math.min(blessSystem.config.endLevel, getPlayerLevel(cid)) - blessSystem.config.startLevel) * blessSystem.config.levelCost))
- end
- price = price * 5 * 1.2
- if(blessSystem.needPremium and not isPremium(cid)) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a premium account to use blessings.")
- return false
- end
- for i = 1, 5 do
- if(getPlayerBlessing(cid, i)) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have all blessings.")
- return false
- end
- end
- if(not doPlayerRemoveMoney(cid, price)) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have enough money for blessings. (You need " .. price .. " gp's)")
- return false
- end
- for i = 1, 5 do
- doPlayerAddBlessing(cid, i)
- end
- doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have been blessed by the gods!")
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
- return true
- end
- ]]></lib>
- <talkaction words="!blesscheck;!blesstest" event="script"><![CDATA[
- domodlib('bless-system-config')
- local BLESSINGS = {"Wisdom of Solitude", "Spark of the Phoenix", "Fire of the Suns", "Spiritual Shielding", "Embrace of Tibia"}
- function onSay(cid, words, param)
- local result = ""
- for i = 1, (table.maxn(BLESSINGS) - 1) do
- result = (getPlayerBlessing(cid, i) and result .. (result:len() > 0 and ", " or "") .. BLESSINGS[i] or result)
- end
- return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result:len() > 0 and "Currently you have the following blessings: " .. result .. "." or "You do not have any blessing.")
- end
- ]]></talkaction>
- <talkaction words="!bless;/bless" event="script"><![CDATA[
- domodlib('bless-system-config')
- domodlib('bless-system-lib')
- function onSay(cid, words, param, channel)
- blessSystem.buyAllBlessings(cid)
- return true
- end
- ]]></talkaction>
- <action uniqueid="32001" event="script"><![CDATA[
- domodlib('bless-system-config')
- domodlib('bless-system-lib')
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- blessSystem.buyAllBlessings(cid)
- return true
- end
- ]]></action>
- <!-- Refill Boots Command -->
- <description>
- This mod adds a new command to the server, that can be used to refill (more precisely: change one id to another id
- for fixed price). More items can be added by modifying 'items' table.
- </description>
- <config name="command-refill-config"><![CDATA[
- items = {
- ["soft"] = { -- soft boots
- id = 10021,
- new_id = 2640,
- price = 10000,
- message = "Soft boots has been refilled."
- },
- ["firewalker"] = { -- firewalker boots
- id = 10022,
- new_id = 9932,
- price = 50000,
- message = "Firewalker boots has been refilled."
- }
- }
- ]]></config>
- <lib name="command-refill-lib"><![CDATA[
- domodlib('command-refill-config')
- command_refill = {
- items = items,
- buy = function (cid, name)
- local item = command_refill.items[name]
- if(not item) then
- print('custom-commands.xml - invalid item name used (' .. name .. ')')
- return false
- end
- if(getPlayerItemCount(cid, item.id) >= 1) then
- if(getPlayerMoney(cid) >= item.price) then
- if(doPlayerRemoveItem(cid, item.id, 1)) then
- doPlayerBuyItem(cid, item.new_id, 1, item.price, 1)
- if(item.message) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, item.message)
- end
- return true
- end
- else
- doPlayerSendCancel(cid, "Not enough money.")
- end
- else
- doPlayerSendCancel(cid, "Item not found in your inventory.")
- end
- return false
- end
- }
- ]]></lib>
- <talkaction words="!refill" event="script"><![CDATA[
- domodlib('command-points-lib')
- function onSay(cid, words, param, channel)
- param = param:lower():trim()
- if(param == '') then
- local str = ""
- for name, item in pairs(command_refill.items) do
- str = str .. "!" .. name .. "\n"
- end
- doPlayerPopupFYI(cid, str)
- return true
- end
- local item = command_refill.items[param]
- if(not item) then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid option.")
- return true
- end
- command_refill.buy(cid, item.name)
- return true
- end
- ]]></talkaction>
- <talkaction words="!soft" event="script"><![CDATA[
- domodlib('command-refill-lib')
- function onSay(cid, words, param, channel)
- command_refill.buy(cid, "soft")
- return true
- end
- ]]></talkaction>
- <talkaction words="!firewalker" event="script"><![CDATA[
- domodlib('command-refill-lib')
- function onSay(cid, words, param, channel)
- command_refill.buy(cid, "firewalker")
- return true
- end
- ]]></talkaction>
- <!-- Promotion(npc) command -->
- <config name="command-promotion-config"><![CDATA[
- -- how much gold coins does it cost
- cost = 20000
- -- required level to buy a promotion
- minLevel = 20
- -- need premium account to use command?
- needPremium = "yes"
- -- maximum promotion level player can advance to (default = 1). Can be ignored if there are not any new vocations on the server.
- maxPromotionLevel = 1
- ]]></config>
- <talkaction words="!promotion" event="script"><![CDATA[
- domodlib('command-promotion-config')
- local config = {
- cost = cost,
- minLevel = minLevel,
- needPremium = needPremium,
- maxPromotionLevel = maxPromotionLevel
- }
- config.needPremium = getBooleanFromString(config.needPremium)
- function onSay(cid, words, param, channel)
- if(config.needPremium and not isPremium(cid)) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a premium account to get promotion.")
- return true
- end
- if(getPlayerPromotionLevel(cid) >= config.maxPromotionLevel) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are already promoted.")
- elseif(getPlayerLevel(cid) < config.minLevel) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. config.minLevel .. " to get promotion.")
- elseif(doPlayerRemoveMoney(cid, config.cost) ~= TRUE) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have enought money! (Promotion cost " .. config.cost .. " gold coins.")
- else
- setPlayerPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
- end
- return true
- end
- ]]></talkaction>
- <!-- Me Player Save Command -->
- <config name="command-save-config"><![CDATA[
- exhaust = 3 -- in minutes
- storage = 3003 -- storage value used to save exhaustion
- ]]></config>
- <talkaction words="!saveme;/saveme" event="script"><![CDATA[
- domodlib('command-save-config')
- local config = {
- exhaust = exhaust,
- storage = storage
- }
- function onSay(cid, words, param, channel)
- if(exhaust.check(cid, config.storage)) then
- doPlayerSendCancel(cid, "You can save yourself only once per " .. config.exhaust .. " minutes.")
- return true
- end
- if(doPlayerSave(cid)) then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your character has been succesfully saved.")
- exhaust.set(cid, config.storage, config.exhaust * 60)
- else
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Error while saving your character. Please try again later.")
- end
- return true
- end
- ]]></talkaction>
- <!-- Guild Cast Command -->
- <config name="guild-cast-config"><![CDATA[
- exhaust = 10 -- in seconds
- storage = 3001 -- storage value used to save exhaustion
- storageColor = 3002 -- storage value used to save previously used message color
- ]]></config>
- <talkaction words="!gc;/gc" event="script"><![CDATA[
- domodlib('guild-cast-config')
- local config = {
- exhaustion = exhaust,
- storage = storage,
- storageColor = storageColor
- }
- function onSay(cid, words, param, channel)
- if(exhaustion.check(cid, config.storage)) then
- doPlayerSendCancel(cid, "You can broadcast message only one time per " .. config.exhaustion .. " seconds.")
- return true
- end
- if(param == '') then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to type a message to broadcast!")
- return true
- end
- local playerGuild = getPlayerGuildId(cid)
- if(playerGuild == false) then
- doPlayerSendCancel(cid, "Sorry, you're not in a guild.");
- return true
- end
- if(getPlayerGuildLevel(cid) < GUILDLEVEL_VICE) then
- doPlayerSendCancel(cid, "You have to be at least Vice-Leader to guildcast!")
- return true
- end
- local messageType = MESSAGE_STATUS_WARNING
- local t = string.explode(param, ";")
- if(not t[2]) then
- if(getPlayerStorageValue(cid, config.storageColor) ~= -1) then
- messageType = getPlayerStorageValue(cid, config.storageColor)
- end
- else
- if(MESSAGE_TYPES[t[1]] ~= nil) then
- messageType = MESSAGE_TYPES[t[1]]
- end
- param = t[2]
- end
- if(messageType < MESSAGE_FIRST or messageType > MESSAGE_LAST) then
- messageType = MESSAGE_STATUS_WARNING
- --setPlayerStorageValue(cid, MESSAGE_STATUS_WARNING, messageType)
- --doPlayerSendCancel(cid, "Unknown message type.")
- --return true
- end
- local players = getPlayersOnline()
- local message = "*Guild* " .. getCreatureName(cid) .. " [" .. getPlayerLevel(cid) .. "]:\n" .. param
- local members = 0
- for i, tid in ipairs(players) do
- if(getPlayerGuildId(tid) == playerGuild) then
- doPlayerSendTextMessage(tid, messageType, message)
- members = members + 1
- end
- end
- setPlayerStorageValue(cid, config.storageColor, messageType)
- exhaustion.set(cid, config.storage, config.exhaustion)
- doPlayerSendCancel(cid, "Message sent to your guild members. (Total: " .. members .. ")")
- return true
- end
- ]]></talkaction>
- <!-- Guild Outfit Command -->
- <config name="guild-outfit-config"><![CDATA[
- exhaust = 30 -- in seconds
- storage = 3005 -- storage value used to save exhaustion
- ]]></config>
- <talkaction words="!go;/go" event="script"><![CDATA[
- domodlib('guild-outfit-config')
- local config = {
- exhaust = exhaust,
- storage = storage
- }
- function onSay(cid, words, param, channel)
- if(exhaust.check(cid, config.storage)) then
- doPlayerSendCancel(cid, "You can change outfit only 1 time per " .. config.exhaust .. " seconds.")
- return true
- end
- local playerGuild = getPlayerGuildId(cid)
- if(not playerGuild or playerGuild == 0) then
- doPlayerSendCancel(cid, "Sorry, you're not in a guild.")
- return true
- end
- if(getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
- doPlayerSendCancel(cid, "You have to be Leader of your guild to change outfits!")
- return true
- end
- local outfit, members = getCreatureOutfit(cid), 0
- local message = "*Guild* Your outfit has been changed by leader. (" .. getCreatureName(cid) .. ")"
- for _, tid in ipairs(getPlayersOnline()) do
- if(getPlayerGuildId(tid) == playerGuild and cid ~= tid) then
- local newOutfit = outfit
- if(not canPlayerWearOutfit(tid, outfit.lookType, outfit.lookAddons)) then
- local tmpOutfit = getCreatureOutfit(tid)
- newOutfit.lookAddons = 0--tmpOutfit.lookAddons
- if(not canPlayerWearOutfit(tid, outfit.lookType, 0)) then
- newOutfit.lookType = tmpOutfit.lookType
- end
- end
- doSendMagicEffect(getCreaturePosition(tid), 66)
- doCreatureChangeOutfit(tid, newOutfit)
- doPlayerSendTextMessage(tid, MESSAGE_INFO_DESCR, message)
- members = members + 1
- end
- end
- exhaust.set(cid, config.storage, config.exhaust)
- doPlayerSendCancel(cid, "Guild members outfit has been changed. (Total: " .. members .. ")")
- return true
- end
- ]]></talkaction>
- <!-- Buy Command -->
- <config name="command-buy-config"><![CDATA[
- items = {
- ['brown backpack'] = {cost = 500, id = 1988},
- ['green backpack'] = {cost = 500, id = 1998},
- ['yellow backpack'] = {cost = 500, id = 1999},
- ['red backpack'] = {cost = 500, id = 2000},
- ['purple backpack'] = {cost = 500, id = 2001},
- ['grey backpack'] = {cost = 500, id = 2003},
- ['blue backpack'] = {cost = 500, id = 2002},
- ['gold backpack'] = {cost = 500, id = 2004},
- ['amulet of loss'] = {cost = 300000, id = 2173},
- ['rope'] = {cost = 500, id = 2120},
- ['shovel'] = {cost = 500, id = 2554},
- ['machete'] = {cost = 500, id = 2420},
- ['fishing rod'] = {cost = 500, id = 2580}
- }
- ]]></config>
- <talkaction words="!buy;/buy" event="script"><![CDATA[
- domodlib('command-buy-config')
- local config = {
- items = items
- }
- function onSay(cid, words, param, channel)
- if(param == '') then
- local str = ""
- for name, options in pairs(config.items) do
- str = str .. "\n" .. name
- end
- doPlayerPopupFYI(cid, "/buy or !buy:\n\n" .. str)
- return true
- end
- local item = config.items[param]
- if(item ~= nil) then
- if(not doPlayerRemoveMoney(cid, item.cost)) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Not enough money to buy " .. param .. ".\n(" .. item.cost .. "gp)")
- return true
- end
- local amount = item.amount and item.amount or 1
- doPlayerAddItem(cid, item.id, amount)
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
- else
- doPlayerSendCancel(cid, "Item not found. Use '!buy' to see the list.")
- end
- return true
- end
- ]]></talkaction>
- <!-- Send animated text -->
- <talkaction words="!me;/me" event="buffer" value="doCreatureSay(cid, getCreatureName(cid) .. ' ' .. param, TALKTYPE_MONSTER)"/>
- <!-- Check Player Spells -->
- <talkaction words="!spells;/spells" event="script"><![CDATA[
- function onSay(cid, words, param)
- local t = {}
- for i = 0, getPlayerInstantSpellCount(cid) - 1 do
- local spell = getPlayerInstantSpellInfo(cid, i)
- if(spell.level ~= 0) then
- if(spell.manapercent > 0) then
- spell.mana = spell.manapercent .. "%"
- end
- table.insert(t, spell)
- end
- end
- table.sort(t, function(a, b) return a.level < b.level end)
- local text, prevLevel = "", -1
- for i, spell in ipairs(t) do
- local line = ""
- if(prevLevel ~= spell.level) then
- if(i ~= 1) then
- line = "\n"
- end
- line = line .. "Spells for Level " .. spell.level .. "\n"
- prevLevel = spell.level
- end
- text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
- end
- doShowTextDialog(cid, 2175, text)
- return true
- end
- ]]></talkaction>
- <!-- Check Members Guild inGame -->
- <talkaction words="!guildmeb;/guildmeb" event="script"><![CDATA[
- function onSay(cid, words, param, channel)
- if param == '' then
- local list = db.getResult("SELECT `name` FROM `guilds`;")
- if(list:getID() ~= -1) then
- local v = ''
- repeat
- v = v .. list:getDataString("name") .. "\n"
- until not list:next()
- list:free()
- doShowTextDialog(cid, 2529, v)
- else
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no guilds on this server.")
- end
- else
- local id = getGuildId(param)
- if id then
- local list = db.getResult("SELECT `name`, `rank_id` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = " .. id .. ");")
- if(list:getID() ~= -1) then
- local v = ''
- repeat
- local rank = db.getResult("SELECT `name` FROM `guild_ranks` WHERE `id` = " .. list:getDataInt("rank_id") .. " LIMIT 1;")
- v = v .. list:getDataString("name") .. " [" .. rank:getDataString("name") .. "]\n"
- rank:free()
- until not list:next()
- list:free()
- doShowTextDialog(cid, 2529, v)
- else
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no players in this guild.")
- end
- else
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This guild doesn't exist.")
- end
- end
- return true
- end
- ]]></talkaction>
- <!-- Full Stamina Command at player -->
- <talkaction words="!stamina;/stamina" event="script"><![CDATA[
- function onSay(cid, words, param)
- if getPlayerMoney(cid) >= 250000 then
- doPlayerRemoveMoney(cid, 250000)
- doPlayerSetStamina(cid, 2520)
- else
- doPlayerSendCancel(cid, "Nesesitas 25 crystal coins para llenarte la stamina.")
- end
- return true
- end
- ]]></talkaction>
- <!-- Info mana - exp -->
- <talkaction words="!mana" event="script"><![CDATA[
- function onSay(cid, words, param, channel)
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to spent " .. (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, TRUE) + 1) - getPlayerSpentMana(cid)) ..
- " mana to next magic level.")
- return true
- end
- ]]></talkaction>
- <talkaction words="!exp" event="script"><![CDATA[
- function onSay(cid, words, param, channel)
- local expinfo = getPlayerExperience(cid)
- if (words == "!exp") then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. expinfo.. " experience points to next level")
- end
- return true
- end
- ]]></talkaction>
- <!-- GiveReward Item to player -->
- <talkaction words="/giveitem" group="4" access="3" event="script" log="yes"><![CDATA[
- function onSay(cid, words, param, channel)
- if(param == '') then
- return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
- end
- local t = string.explode(param, ",")
- local id = tonumber(t[1])
- if not id then
- id = getItemIdByName(t[1], false)
- if not id then
- return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item with such name does not exist.")
- end
- end
- t[2] = tonumber(t[2])
- local amount = t[2] or 1
- for _, pid in ipairs(getPlayersOnline()) do
- doDecayItem(doPlayerAddItem(pid, id, amount))
- end
- return true
- end
- ]]></talkaction>
- <!-- GiveReward Item to player -->
- <talkaction words="!giveitem" group="4" access="3" event="script" log="yes"><![CDATA[
- function onSay(cid, words, param, channel)
- local param = string.explode(param, ",")
- local item = {
- player = getPlayerByNameWildcard(param[1]),
- itemid = tonumber(param[2]),
- type = tonumber(param[3]),
- charges = 1
- }
- local str = {
- "",
- ""
- }
- if(item.player == 0 or item.player == nil) then
- doPlayerSendCancel(cid, "Player " .. param[1] .. " is not online.")
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
- return true
- end
- if(not item.itemid) then
- item.itemid = getItemIdByName(param[2], true)
- if not item.itemid then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
- return true
- end
- end
- if(item.itemid < 1) then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No item specified.")
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
- return true
- end
- if(not item.type) then
- if(isItemRune(item.itemid) or isItemStackable(item.itemid)) == true then
- item.type = 100
- item.charges = 1
- else
- item.type = 1
- item.charges = 1
- end
- end
- if(isItemMovable(item.itemid) == true) then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give that item.")
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
- return true
- end
- local str = {
- "You give " .. item.type .."x " .. getItemNameById(item.itemid) .. " to " .. param[1] .. ".",
- "You received " .. item.type .. "x " .. getItemNameById(item.itemid) .. " from " .. getCreatureName(cid) .. "."
- }
- if(isItemRune(item.itemid) == true) then
- item.charges = item.type
- item.type = 1
- str[1] = "You give " .. item.type .. "x " .. getItemNameById(item.itemid) .. " with " .. item.charges .. "x charges to " .. param[1] .. "."
- str[2] = "You received " .. item.type .. "x " .. getItemNameById(item.itemid) .. " with " .. item.charges .. " charges from " .. getCreatureName(cid) .. "."
- end
- doPlayerGiveItem(item.player, item.itemid, item.type, item.charges)
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str[1])
- doSendMagicEffect(getCreaturePosition(item.player), CONST_ME_MAGIC_RED)
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str[2])
- return true
- end
- ]]></talkaction>
- <!-- Bank Command -->
- <config name="command-bank-config"><![CDATA[
- transferDisabledVocations = {0} -- disable non vocation characters
- ]]></config>
- <talkaction words="!bank;/bank" event="script"><![CDATA[
- domodlib('command-bank-config')
- local config = {
- transferDisabledVocations = transferDisabledVocations
- }
- local function validAmount(amount)
- return (isNumber(amount) and amount > 0 and amount < 4294967296)
- end
- local function getAmount(amount, cid, f)
- return (amount == 'all' and f(cid) or tonumber(amount))
- end
- local function getPlayerVocationByName(name)
- local result = db.getResult("SELECT `vocation` FROM `players` WHERE `name` = " .. db.escapeString(name))
- if(result:getID() == -1) then
- return false
- end
- local value = result:getDataString("vocation")
- result:free()
- return value
- end
- function onSay(cid, words, param, channel)
- if(param == '') then
- doPlayerPopupFYI(cid,
- "Bank management manual.\n\n" ..
- "!bank or /bank balance - show your account balance\n" ..
- "!bank or /bank deposit 100 - deposit 100 gold\n" ..
- "!bank or /bank withdraw 50 - withdraw 50 gold\n" ..
- "!bank or /bank transfer 30 God - transfer 30 gold to player God\n\n" ..
- "Tip: you can also use 'all' as amount.\n" ..
- "!bank or /bank deposit all - deposit all gold you have\n" ..
- "!bank or /bank withdraw all - withdraw all gold from your bank account"
- )
- return true
- end
- local t = string.explode(param, " ", 2)
- local command = t[1]:lower()
- if(command == 'balance') then
- doPlayerSendCancel(cid, "Your account balance is " .. getPlayerBalance(cid) .. " gold.")
- elseif(command == 'deposit') then
- if(not t[2]) then
- doPlayerSendCancel(cid, "Amount is required.")
- return true
- end
- local amount = getAmount(t[2], cid, getPlayerMoney)
- if(validAmount(amount) and getPlayerMoney(cid) >= amount and doPlayerDepositMoney(cid, amount)) then
- doPlayerSendCancel(cid, amount .. " gold has been deposited.")
- else
- doPlayerSendCancel(cid, "Not enough money to deposit.")
- end
- elseif(command == 'withdraw') then
- if(not t[2]) then
- doPlayerSendCancel(cid, "Amount is required.")
- return true
- end
- local amount = getAmount(t[2], cid, getPlayerBalance)
- if(validAmount(amount) and getPlayerBalance(cid) >= amount and doPlayerWithdrawMoney(cid, amount)) then
- doPlayerSendCancel(cid, amount .. " gold has been withdrawn.")
- else
- doPlayerSendCancel(cid, "Not enough money to withdraw.")
- end
- elseif(command == 'transfer') then
- if(not t[2]) then
- doPlayerSendCancel(cid, "Amount is required.")
- return true
- end
- if(not t[3]) then
- doPlayerSendCancel(cid, "Player name to transfer is required.")
- return true
- end
- local amount, target = tonumber(t[2]), t[3]
- if(getPlayerGUID(cid) == getPlayerGUIDByName(target)) then
- doPlayerSendCancel(cid, "You cannot transfer money to yourself.")
- elseif(isInArray(config.transferDisabledVocations, getPlayerVocation(cid))) then
- doPlayerSendCancel(cid, "Your vocation cannot transfer money.")
- elseif(not validAmount(amount) or getPlayerBalance(cid) < amount) then
- doPlayerSendCancel(cid, "Not enough money to transfer.")
- else
- local targetVocation = getPlayerVocationByName(target)
- if(not playerExists(target) or not targetVocation or isInArray(config.transferDisabledVocations, targetVocation) or not doPlayerTransferMoneyTo(cid, target, amount)) then
- doPlayerSendCancel(cid, "This player does not exist on this world or have no vocation.")
- else
- doPlayerSendCancel(cid, "You have transferred " .. amount .. " gold to \"" .. target .."\".")
- end
- end
- else
- doPlayerSendCancel(cid, "Invalid command usage. Use '!bank' to view manual.")
- end
- return true
- end
- ]]></talkaction>
- <!-- Rename Command -->
- <config name="rename-config"><![CDATA[
- blacklistParam = {"account manager", "god", "cm", "gm", "tutor", "tester"}
- maxTextLenght = 15
- minWordLenght = 3
- delay = 2
- item = {
- Id = 1111, count = 0
- }
- ]]></config>
- <talkaction words="!changename;/changename;!namechange;/namechange" event="script"><![CDATA[
- domodlib('rename-config')
- local config = {
- blacklistParam = blacklistParam,
- maxTextLenght = maxTextLenght,
- minWordLenght = minWordLenght,
- delay = delay,
- item = item
- }
- function onSay(cid, words, param, channel)
- local textCancel, t = config.text, string.explode(param, ",")
- if(param == '') then
- return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
- elseif((getPlayerGUIDByName(t[1]) ~= nil) and (not getBooleanFromString(t[2]))) then
- textCancel = "That name is already in use."
- elseif(getPlayerItemCount(cid, config.item.Id) < config.item.count) then
- textCancel = "You do not fulfill the requirements."
- elseif(not getTilePzInfo(getCreaturePosition(cid))) then
- textCancel = "You must be inside a protection zone to use this command."
- elseif(string.len(tostring(t[1])) >= config.maxTextLenght) then
- textCancel = "You can only use a maximum of " .. config.maxTextLenght .. " characters."
- elseif(string.find(t[1]:lower(), "[^%l%s]") ~= nil) then
- textCancel = "You cannot use symbols."
- else
- for blacklist = 1, table.maxn(config.blacklistParam) do
- if(string.find(t[1]:lower(), config.blacklistParam[blacklist]) ~= nil) then
- textCancel = "Invalid name entry."
- break
- end
- end
- end
- if(config.text ~= textCancel) then
- doPlayerSendCancel(cid, textCancel)
- return true
- end
- local paramTemp, space, oldName = '', '', getCreatureName(cid)
- for word in string.gmatch(t[1], "%a+") do
- if(string.len(word) < config.minWordLenght) then
- doPlayerSendCancel(cid, "Each word must have a minimum of " .. config.minWordLenght .. " characters.")
- return true
- end
- paramTemp = "" .. paramTemp .. "" .. space .. "" .. word .. ""
- if(space == '') then
- space = " "
- end
- end
- local guid = getPlayerGUID(cid)
- t[1] = paramTemp
- doPlayerRemoveItem(cid, config.item.Id, config.item.count)
- if(pcall(doPlayerChangeName, guid, oldName, t[1]) == false) then
- db.executeQuery("INSERT INTO `player_namelocks` (`player_id`, `name`, `new_name`, `date`) VALUES (" .. guid .. ", " .. db.escapeString(oldName) .. ", " .. db.escapeString(t[1]) .. ", " .. os.time() .. ");")
- db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(t[1]) .. " WHERE `id` = " .. guid .. " LIMIT 1;")
- end
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your name has been changed successfully. You will be kicked in " .. config.delay .. " seconds.")
- addEvent(function(cid, forceLogout)
- if(isPlayer(cid)) then
- doRemoveCreature(cid, forceLogout)
- end
- end, config.delay * 1000, cid, false)
- return true
- end
- ]]></talkaction>
- </mod>
Add Comment
Please, Sign In to add comment