• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TalkAction Command !tp for TFS 0.4 with several options.

Sarah Wesker

ƐƖєgαηт Sуηтαx ❤
Staff member
TFS Developer
Support Team
Joined
Mar 16, 2017
Messages
1,419
Solutions
155
Reaction score
1,976
Location
London
GitHub
MillhioreBT
Twitch
millhiorebt
Hello everyone, here I will leave a perfect command for your servers TFS 0.4
add on talkactions.xml
Code:
<talkaction words="!tp" event="script" value="teleport.lua"/>

add new sheet on data/talkactions/scripts/ per example: teleport.lua for this case.
add this on the sheet:
Code:
local places = {
    --[[ options:
    pos = {x=0,y=0,z=0},
    cost = 000,
    level = 000,
    premium = true or false,
    storage = 0000,
    vocations = { 1, 2, 3, 4 },
    items = { {2074, 2}, {2007, 1} }
    ]]--
    ['temple'] = { pos = { x = 2500, y = 2500, z = 7 }, cost = 0, level = 1, premium = true },
    ['depot'] = { pos = { x = 1000, y = 1000, z = 7 }, cost = 0, level = 1, premium = true }
}

if not isInArray then -- backup function
    function isInArray(array, value)
        for k, v in pairs(array) do
            if v == value then
                return true
            end
        end
        return false
    end
end

local function getStrVocations(vocations)
    local str = ""
    for k, v in pairs(vocations) do
        str = string.format("%s%s%s", str, getVocationInfo(v).name, next(vocations, k) and ", " or ".")
    end
    return str
end

local function getCount(array)
    local count = 0
    for _, k in pairs(array) do
        count = count +1
    end
    return count
end

local function getStrItems(items)
    local str = ""
    for k, v in pairs(items) do
        str = string.format("%s%u %s%s", str, v[2], getItemInfo(v[1]).name, next(items, k) and ", " or ".")
    end
    return str
end

function onSay(cid, words, param)

    local command = unpack(string.explode(param, ","))
    local option = places[string.lower(command or "default")]

    if option then
        if option.premium then
            if getPlayerPremiumDays(cid) <= 0 then
                doPlayerSendCancel(cid, "Sorry, You need to be premium.")
                return true
            end
        end
        if option.storage then
            if getPlayerStorageValue(cid, option.storage) <= 0 then
                doPlayerSendCancel(cid, "Sorry, You are not allowed to travel to this place.")
                return true
            end
        end
        if option.vocations then
            if not isInArray(option.vocations, getPlayerVocation(cid)) then
                doPlayerSendCancel(cid, string.format("Sorry, vocation required: %s", getStrVocations(option.vocations)))
                return true
            end
        end
        if option.items then
            local completed = 0
            for k, v in pairs(option.items) do
                if getPlayerItemCount(cid, v[1]) >= v[2] then
                    completed = completed +1
                end
            end
            if completed == getCount(option.items) then
                for k, v in pairs(option.items) do
                    doPlayerRemoveItem(cid, v[1], v[2])
                end
            else
                doPlayerSendCancel(cid, string.format("Sorry, items required: %s", getStrItems(option.items)))
                return true
            end
        end
        if not getCreatureCondition(cid, CONDITION_INFIGHT) then
            if getPlayerLevel(cid) >= option.level then
                if doPlayerRemoveMoney(cid, option.cost) then
                    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                    doTeleportThing(cid, option.pos)
                    doSendMagicEffect(option.pos, CONST_ME_TELEPORT)
                else
                    doPlayerSendCancel(cid, string.format("You need %u gold coins.", option.cost))
                end
            else
                doPlayerSendCancel(cid, string.format("Sorry, only players level %u can use this command.", option.level))
            end
        else
            doPlayerSendCancel(cid, "Sorry, you have infight condition.")
        end
    else
        doPlayerSendCancel(cid, "Write a position you want to be teleported to.")
    end

    return true
end

If you like me script, let me know. ;)
 
Back
Top