• 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

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,391
Solutions
7
Reaction score
550
Hey Otland,

I made a addon and mount doll script that uses Modal Windows. No more typing "!addon"Demon" All you need to do is use the doll and select the mount/addon from the list.

FEATURES

- Confirm button is not enabled if addon doll is not in backpack
- Error message if using doll in backpack and then throwing on ground
- All outfits/mounts from 10.76
- Tested with TFS 1.1 and 1.2

First up you'll need to register these to events in your login.lua.
Code:
'modalAD',
'modalMD'

Next you will need to make sure you enable the scripts in both your actions.xml and your creaturescripts.xml as following

(data/actions/actions.xml)

Code:
    <action itemid="8982" script="custom/modalAD.lua"/>
    <action itemid="9019" script="custom/modalMD.lua"/>

data/creaturescripts/creaturescripts.xml
Code:
    <event type="modalwindow" name="modalAD" script="custom/modalAD.lua"/>
    <event type="modalwindow" name="modalMD" script="custom/modalMD.lua"/>

Next, Add these into the following paths

Mount Doll
/data/creaturescripts/scripts/modalMD.lua
http://pastebin.com/JeMuWvt8

Addon Doll
/data/creaturescripts/scripts/modalAD.lua
http://pastebin.com/nRF0sje8

Mount Doll
/data/actions/scripts/modalMD.lua
http://pastebin.com/jDJHLa7L

Addon Doll
/data/actions/scripts/modalAD.lua

http://pastebin.com/fiL9cEef

Thats it!

Regards,
Beastn.

CREDITS
@RazorBlade
 
Last edited:
so you were not able to make it to not display already owned things? :'(
 
so you were not able to make it not display already owned things? :'(
Ooopss... i forgot all about that haha it wont be hard to add.. tbh i would rather have the preview there :'(
 
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...
 
so you were not able to make it to not display already owned things? :'(
actually now that i tihnk about it I dont think its possible to hdie already owned ones bcuase there is no command for that... :'(
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...

100% correct man i didn't even think about it.
 
actually now that i tihnk about it I dont think its possible to hdie already owned ones bcuase there is no command for that... :'(
I don't use 1.x so I can't test but wouldn't it be possible to do something like this:

window:addChoice(1, "Citizen")
-- notice I skipped choice 2 here
window:addChoice(3, "Mage")

If this is a possibility then it should be very simple to create a loop that checks if the player can wear the addon, if yes addChoice otherwise skip and move to next addon.

Edit:
Code:
local unowned = 0
for ch, outfit in ipairs(maleOutfits) do
    if(not player:hasOutfit(outfit, 3)) then
        unowned = unowned+1
        window:addChoice(ch, "Uh.. this part might require some adjustment of the script to display the correct outfit name")
    end
end
if(unowned == 0) then
    -- send a message telling them they are awesome and own all addons already!
    return true
end
 
Last edited:
I'm already checking if player has mount/addon that bit was easy. the problem is getting it to skip it. Though i might try doing what Xagul said and see what I can do. I'm still very new to Modalwindows so.. lol
 
I'm already checking if player has mount/addon that bit was easy. the problem is getting it to skip it. Though i might try doing what Xagul said and see what I can do. I'm still very new to Modalwindows so.. lol
Same I am pretty much just guessing here xD I love the concept of modal windows I can't wait to get into the new versions of tibia so I can play with them some day. They have to be the single most useful thing introduced to tibia in a long time and out of all the past updates, probably the most useful thing for the ot community. It will really help us get away from those disgusting /commands and allow us to present information/choices to players with a nice gui.
 
Same I am pretty much just guessing here xD I love the concept of modal windows I can't wait to get into the new versions of tibia so I can play with them some day. They have to be the single most useful thing introduced to tibia in a long time and out of all the past updates, probably the most useful thing for the ot community. It will really help us get away from those disgusting /commands and allow us to present information/choices to players with a nice gui.
Exactly! I'm trying to port everything i can think of to modal windows. If you have any ideas for me let me know and i'll do that shit haha
 
Exactly! I'm trying to port everything i can think of to modal windows. If you have any ideas for me let me know and i'll do that shit haha
make a "premium days shop" where user may use it to select how many premium days he wants to buy, example:

buy premium
bla bla bla bal
choices:
[7 days]
[15 days]
[30 days]
[buy][cancel]

and make admin able to set price into itemID,amount/money(gold coins etc)/premiumPoints(the thing that gesior used to have)
 
make a "premium days shop" where user may use it to select how many premium days he wants to buy, example:

buy premium
bla bla bla bal
choices:
[7 days]
[15 days]
[30 days]
[buy][cancel]

and make admin able to set price into itemID,amount/money(gold coins etc)/premiumPoints(the thing that gesior used to have)
okay.
 
Tested it and doesn't work. I get only You cannot use this object. No errors in console.
 
Back
Top