strutZ
Australian OT Member {AKA Beastn}
- Joined
- Nov 16, 2014
- Messages
- 1,391
- Solutions
- 7
- Reaction score
- 550
Not without source edits :'(Is possible to add images in the modal window???
Not without source edits :'(Is possible to add images in the modal window???
how to make it so that an item is required to get the tapestrys?
function onModalWindow(player, modalWindowId, buttonId, choiceId)
player:unregisterEvent("ModalWindow_Tutorial")
local tapestry = {1869, 1866, 1863, 1860, 1872, 1857}
local requiredItem = 2157 -- id for gold nuggets
local requiredCount = 10
if modalWindowId == 1000 then
if buttonId == 100 then
if player:getItemCount(requiredItem) >= requiredCount then
player:addItem(tapestry[choiceId], 1)
else
player:sendCancelMessage('Sorry, you need 10 gold nuggets to buy this tapestry.')
end
end
end
end
Sometimes I have to put so many text on the window so It misses some words because it doesn't update the size to fits them all. Is there any way to change or solve this?
local message = "----------------------------------- You get a free tapestry in the color of your choice! --------------------------------"
local window = ModalWindow(1000, title, message)
one more question how to make an npc pop up a model window
local function sendModalWindowToPlayer(player)
player:registerEvent("ModalWindow_Tutorial")
local title = "Pick your favorite color!"
local message = "You get a free tapestry in the color of your choice!"
local window = ModalWindow(1000, title, message)
window:addButton(100, "Confirm")
window:addButton(101, "Cancel")
window:addChoice(1, "Red")
window:addChoice(2, "Orange")
window:addChoice(3, "Yellow")
window:addChoice(4, "Green")
window:addChoice(5, "Blue")
window:addChoice(6, "Purple")
window:setDefaultEnterButton(100)
window:setDefaultEscapeButton(101)
window:sendToPlayer(player)
end
sendModalWindowToPlayer(player)
function onModalWindow(player, modalWindowId, buttonId, choiceId)
player:unregisterEvent("Supply")
local tapestry = {1869, 1866, 1863, 1860, 1872, 1857}
local requiredItem = 2157 -- id for gold nuggets
local requiredCount = 10
if modalWindowId == 1000 then
if buttonId == 100 then
if player:getItemCount(requiredItem) >= requiredCount then
player:addItem(tapestry[choiceId], 1)
player:removeItem(2157, 10)
else
player:sendCancelMessage('Sorry, you need 10 gold nuggets to buy this tapestry.')
end
elseif modalWindowId == 1000 then
if buttonId == 100 then
if choiceId == 2 then
if player:getItemCount(requiredItem) >= requiredCount then
player:addItem(tapestry[choiceId], 2)
player:removeItem(2157, 30)
else
player:sendCancelMessage('Sorry, you need 10 gold nuggets to buy this tapestry.')
end
end
end
end
i tried to loop it like this dont seem to do anything tho
Code:function onModalWindow(player, modalWindowId, buttonId, choiceId) player:unregisterEvent("Supply") local tapestry = {1869, 1866, 1863, 1860, 1872, 1857} local requiredItem = 2157 -- id for gold nuggets local requiredCount = 10 if modalWindowId == 1000 then if buttonId == 100 then if player:getItemCount(requiredItem) >= requiredCount then player:addItem(tapestry[choiceId], 1) player:removeItem(2157, 10) else player:sendCancelMessage('Sorry, you need 10 gold nuggets to buy this tapestry.') end elseif modalWindowId == 1000 then if buttonId == 100 then if choiceId == 2 then if player:getItemCount(requiredItem) >= requiredCount then player:addItem(tapestry[choiceId], 2) player:removeItem(2157, 30) else player:sendCancelMessage('Sorry, you need 10 gold nuggets to buy this tapestry.') end end end end
function onModalWindow(player, modalWindowId, buttonId, choiceId)
player:unregisterEvent("ModalWindow_Tutorial")
local tapestries = {
{tapestryId = 1869, requiredItemId = 2157, requiredItemCount = 55},
{tapestryId = 1866, requiredItemId = 2160, requiredItemCount = 88},
{tapestryId = 1863, requiredItemId = 2152, requiredItemCount = 4},
{tapestryId = 1860, requiredItemId = 2148, requiredItemCount = 15},
{tapestryId = 1872, requiredItemId = 2157, requiredItemCount = 5},
{tapestryId = 1857, requiredItemId = 2157, requiredItemCount = 11}
}
if modalWindowId == 1000 then
if buttonId == 100 then
local selection = tapestries[choiceId]
if not selection then
return player:sendCancelMessage('[ERROR]: Sorry, your selection was not found.')
end
if player:getItemCount(selection.requiredItemId) >= selection.requiredItemCount then
player:addItem(selection.tapestryId, 1)
else
player:sendCancelMessage('Sorry, you need ' .. selection.requiredItemCount .. ' ' .. ItemType(selection.requiredItemId):getPluralName() .. ' to buy a ' .. ItemType(selection.tapestryId):getName() .. '.')
end
end
end
end
ahh ok thanksSorry I shouldn't have said loop, actually I meant we can re-structure the table so that it's more dynamic now and we're able to keep our code short and neat!
Code:function onModalWindow(player, modalWindowId, buttonId, choiceId) player:unregisterEvent("ModalWindow_Tutorial") local tapestries = { {tapestryId = 1869, requiredItemId = 2157, requiredItemCount = 55}, {tapestryId = 1866, requiredItemId = 2160, requiredItemCount = 88}, {tapestryId = 1863, requiredItemId = 2152, requiredItemCount = 4}, {tapestryId = 1860, requiredItemId = 2148, requiredItemCount = 15}, {tapestryId = 1872, requiredItemId = 2157, requiredItemCount = 5}, {tapestryId = 1857, requiredItemId = 2157, requiredItemCount = 11} } if modalWindowId == 1000 then if buttonId == 100 then local selection = tapestries[choiceId] if not selection then return player:sendCancelMessage('[ERROR]: Sorry, your selection was not found.') end if player:getItemCount(selection.requiredItemId) >= selection.requiredItemCount then player:addItem(selection.tapestryId, 1) else player:sendCancelMessage('Sorry, you need ' .. selection.requiredItemCount .. ' ' .. ItemType(selection.requiredItemId):getPluralName() .. ' to buy a ' .. ItemType(selection.tapestryId):getName() .. '.') end end end end
Can i used it on tibia 8.54 ? Need this :
what you're asking for is an entirely different source editPlease note that this is only for TFS 1.0+ and Tibia version 9.7 or later.
Can you help me with this?what you're asking for is an entirely different source edit
you sure can! just make the greeting message call the window.i can use modal windows with npc's?
Guys, is there any way to change the background color and button styles? Thank you!
Yes, OTClient...Are you using OTClient?
Yes, OTClient...
Thank you @imkingran !! You are the best!otclient/modules/game_modaldialog/modaldialog.otui at master · edubart/otclient
An alternative tibia client for otserv written in C++11 and Lua, made with a modular system that uses lua scripts for ingame interface and functionality, making otclient flexible and easy to custom...github.com