• 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!

[TFS 1.3] [Revscriptsys] Easy to configure mount selling modal window

Lundrial

lundrial:getTitle()
Premium User
Joined
Apr 15, 2014
Messages
141
Best answers
0
Reaction score
78
Location
Chile
I was too lazy to include zones to tame mounts so I made a mount seller modal window via talkactions in revscriptsys, it may be useful for someone:
Features:
Doesn't show mounts you already own/don't have the items to get
Includes a list with all the mounts locked and what item/quantity it needs
Easy to add new mounts

make a .lua file on data/scripts/talkactions or wherever you want in scripts folder and add:
Lua:
local mounts = {
    [1] = {name = 'Widow Queen', id = 1, item = 13307, count = 2}, -- Self explanatory
    [2] = {name = 'Racing Bird', id = 2, item = 13298, count = 5},
}

local mount = TalkAction("!mount")
function mount.onSay(player, words, param)
    if param == "unlock" then
        player:registerEvent("Mount_Modal_Window")
        local title = "Mount Unlocker"
        local message = "List of available mounts to unlock:"
    
        local window = ModalWindow(1800, title, message)
        window:addButton(100, "Unlock")
        window:addButton(101, "Cancel")
    
        for i = 1, #mounts do
            if (player:getItemCount(mounts[i].item) >= mounts[i].count) and (not player:hasMount(mounts[i].id)) then
                window:addChoice(i,""..mounts[i].name)
            end
        end

        window:setDefaultEnterButton(100)
        window:setDefaultEscapeButton(101)
        
        window:sendToPlayer(player)
    elseif param == "list" then
        local list = "List of locked mounts and item needed:"
        for j = 1, #mounts do
            if not player:hasMount(mounts[j].id) then
                list = list ..'\n['.. mounts[j].name..'] \nItem: ' ..ItemType(mounts[j].item):getName() ..' x'..mounts[j].count
            end
        end
        player:showTextDialog(8977, list)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '\nMount Commands:\n!mount list -- Shows locked mounts\n!mount unlock -- Unlock mounts')
    end
    return false
end

mount:separator(" ")
mount:register()

local mountmodal = CreatureEvent("Mount_Modal_Window")
mountmodal:type("modalwindow")

function mountmodal.onModalWindow(player, modalWindowId, buttonId, choiceId)
    if modalWindowId == 1800 then
        if buttonId == 100 then
            if doPlayerRemoveItem(player, mounts[choiceId].item, mounts[choiceId].count) then
                player:addMount(mounts[choiceId].id)
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, ''.. mounts[choiceId].name ..' unlocked!')
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Couldn\'t unlock mount.')
            end
        end
    end
    player:unregisterEvent("Mount_Modal_Window")
    return true
end

mountmodal:register()
Pics:
1580355629227.png
1580355652064.png

1580355700552.png

1580355726943.png
 

Evil Puncker

Unlucky
Premium User
Joined
May 30, 2009
Messages
6,295
Best answers
55
Reaction score
2,091
very nice one! I wish outfits and addons were that easy to do tho :p
 
Top