• 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.1/1.2 10.76 Modal Window Addon and Mount Doll

I added the files in
\data\actions\scripts\custom

Alright so you added in all the commands.. and when you use the doll nothing happens and you get no errors... What server version you using? did you reload both creaturescripts and actions? did you regsiter the events in your login.lua?
 
I am using the 1.2 version latest commit
This my login.lua
Code:
function onLogin(player)
    local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. " Please choose your outfit."
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    -- Stamina
    nextUseStaminaTime[player.uid] = 0
   
    -- Promotion
    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    if player:isPremium() then
        local value = player:getStorageValue(STORAGEVALUE_PROMOTION)
        if not promotion and value ~= 1 then
            player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
        elseif value == 1 then
            player:setVocation(promotion)
        end
    elseif not promotion then
        player:setVocation(vocation:getDemotion())
    end

    -- Events
    player:registerEvent("PlayerDeath")
    player:registerEvent("DropLoot")
    player:registerEvent("modalAD")
    player:registerEvent("modalMD")
    return true
end
 
Code:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    player:registerEvent("ModalAD")

    local title = "Choose your outfit!"
    local message = "You will receive the outfit and both addons!"

    local window = ModalWindow(1000, title, message)

    window:addButton(100, "Confirm")
    window:addButton(101, "Cancel")

    window:addChoice(1, "Citizen")
    window:addChoice(2, "Hunter")
    window:addChoice(3, "Mage")
    window:addChoice(4, "Knight")
    window:addChoice(5, "Noble")
    window:addChoice(6, "Summoner")
    window:addChoice(7, "Warrior")
    window:addChoice(8, "Barbarian")
    window:addChoice(9, "Druid")
    window:addChoice(10, "Wizard")
    window:addChoice(11, "Oriental")
    window:addChoice(12, "Pirate")
    window:addChoice(13, "Assassin")
    window:addChoice(14, "Beggar")
    window:addChoice(15, "Shaman")
    window:addChoice(16, "Norse")
    window:addChoice(17, "Nightmare")
    window:addChoice(18, "Jester")
    window:addChoice(19, "Brotherhood")
    window:addChoice(20, "Demon Hunter")
    window:addChoice(21, "Yalaharian")
    window:addChoice(22, "Wedding")
    window:addChoice(23, "Warmaster")
    window:addChoice(24, "Wayfarer")
    window:addChoice(25, "Afflicted")
    window:addChoice(26, "Elementalist")
    window:addChoice(27, "Deepling")
    window:addChoice(28, "Insectoid")
    window:addChoice(29, "Entrepreneur")
    window:addChoice(30, "Crystal Warlord")
    window:addChoice(31, "Soil Guardian")
    window:addChoice(32, "Demon")
    window:addChoice(33, "Cave Explorer")
    window:addChoice(34, "Dream Warden")
    window:addChoice(35, "Glooth Engineer")
    window:addChoice(36, "Jersey")
    window:addChoice(37, "Champion")
    window:addChoice(38, "Conjurer")
    window:addChoice(39, "Beast Master")
    window:addChoice(40, "Chaos Acolyte")
    window:addChoice(41, "Death Herald")
    window:addChoice(42, "Ranger")
    window:addChoice(43, "Ceremonial")
    window:addChoice(44, "Puppeteer")
    window:addChoice(45, "Spirit Caller")

    window:setDefaultEnterButton(100)
    window:setDefaultEscapeButton(101)

    window:sendToPlayer(player)
    return true
end
 
so you were not able to make it to not display already owned things? :'(
I did a system like this one a long time ago, I don't know if I still have it, but you have to edit source to make it work without "bugs" (there's a problem with the check of premium outfits).
 
I did a system like this one a long time ago, I don't know if I still have it, but you have to edit source to make it work without "bugs" (there's a problem with the check of premium outfits).
Razor blade showed me a way. I've done it ;) I'll post soon
 
What problem is that o.o
I did a system like this one a long time ago, I don't know if I still have it, but you have to edit source to make it work without "bugs" (there's a problem with the check of premium outfits).
 
In fact they don't show to non-premium people, I don't remember how to reproduce the "bug" anyway... I'll download TFS tomorrow and test it.

@EDIT: The error wasn't in the addon doll, was on the outfit doll... And yeah, was totally my bad because I DID show the premium outfits :p
 
Last edited:
Hm, that's odd o: if it doesn't display to non-premium people, there shouldn't be an issue, unless you're trying to display the 4 non-premium outfits to them, since the addons are premium.
 
It's working now. Yay. But i found a thing. If you put the doll on the floor you can get unlimited addons/mounts
 
I think it would be unsafe to do this.
Code:
player:addOutfitAddon(maleOutfits[choiceId], 3)
player:addOutfitAddon(femaleOutfits[choiceId], 3)
player:removeItem(8982, 1)

Wouldn't it be possible for someone to click the mount/addon doll to bring up the window, then have a bot toss the doll onto the ground and click accept? Would result in them getting the addon and keeping the doll.

I think a better solution would be something like this:
Code:
local maleOutfits = {128, 129, 130, 131, 132, 133, 134, 147, 148, 149, 150, 151, 152, 153, 154, 251, 268, 273, 278, 289, 325, 328, 335, 367, 430, 432, 463, 465, 472, 512, 516, 541, 574, 577, 610, 619, 633, 634, 637, 664, 667, 684, 695, 697, 699}
local femaleOutfits = {136, 137, 141, 139, 140, 138, 142, 143, 144, 145, 146, 155, 156, 157, 158, 252, 269, 270, 279, 288, 324, 329, 336, 431, 433, 464, 466, 471, 513, 514, 542, 575, 578, 618, 620, 632, 578, 636, 665, 578, 683, 694, 696, 698}
 
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("modalad")

    if modalWindowId == 1000 then
        if buttonId == 100 then
            if player:hasOutfit(femaleOutfits[choiceId], 3) or player:hasOutfit(maleOutfits[choiceId], 3) then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You already have these addons.')
                return false
            end
            if(not player:removeItem(8982, 1)) then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Your doll appears to be missing, please try again!')
                return false
            end
         
            player:addOutfitAddon(maleOutfits[choiceId], 3)
            player:addOutfitAddon(femaleOutfits[choiceId], 3)
            player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
        end
    end
end

Would also need to do it for the mounts as well...


Can original post be edited to use this system instead? To avoid the bug of tossing the doll on ground
 
Can original post be edited to use this system instead? To avoid the bug of tossing the doll on ground
With the version I gave to him, it solves that and adds better functionality, but the original post can't be edited without a moderator. hey @Red how would you like to help us out? :p
 
Back
Top