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

Solved Modal Windows problems

nevix

Tunzodus.net
Joined
Mar 31, 2010
Messages
356
Reaction score
62
Location
Lithuanian
Hello guys, I dont understand why its not working, it working only one time and after once it not working.

The code:

talkactions:

Code:
function onSay(cid, words, param)

local player = Player(cid)
   
        if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end
   

   
    local Admincp = ModalWindow(4, "Admincp", "Make your choice:")
Admincp:addChoice(1, "1. Teleports")



    Admincp:addButton(1, 'Go')
    Admincp:addButton(2, 'Exit')
    Admincp:sendToPlayer(player)
   

    return false
   
end


And creaturescripts:

Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)
if modalWindowId == 4 then


local player = Player(cid)

if buttonId == 2 then
return false
else

    if choiceId == 1 then


    local Admincp = ModalWindow(4, 'Open Teleport.', "Make your choice:")
   

Admincp:addChoice(11, "1. Thais")
Admincp:addChoice(12, "2. Carlin")

    Admincp:addButton(9, 'Open')
    Admincp:addButton(10, 'Exit')

    Admincp:sendToPlayer(cid)
   
       return true
    end



if buttonId == 9 then
if choiceId == 11 then
local number = 28001
end
if choiceId == 12 then
local number = 28002
end



cooldown = 10
itemid = 11798
local storage = 16002
local position = getCreaturePosition(cid)
local x = position.x
local y = position.y-1
local z = position.z
portalwhere = {x = x, y = y, z = z}
sec = 10



    if getPlayerStorageValue(cid, storage) >= os.time() then
        return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Wait ".. getPlayerStorageValue(cid, storage) - os.time().." Sec. Until you can walk again.")
    else
   
   
local portal = doCreateItem(itemid,1,portalwhere)

setPlayerStorageValue(cid, 27001, x)
setPlayerStorageValue(cid, 27002, y)
setPlayerStorageValue(cid, 27003, z)

doSetItemActionId(portal, 28001)

local portaldelx = getPlayerStorageValue(cid,27001)
local portaldely = getPlayerStorageValue(cid,27002)
local portaldelz = getPlayerStorageValue(cid,27003)
local portaldelete = {x =portaldelx, y= portaldely, z= portaldelz}

addEvent(function() doRemoveItem(getTileItemById(portaldelete, itemid).uid) end, sec * 1000)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Teleport created for 10 seconds.")
setPlayerStorageValue(cid, storage, os.time() + cooldown)

end
end
end







end
end


Just explain for me why it working only once, and how to solve it?
 
I dont know but I Think problem was action id and unique id attributes, instead of unique ids i'm using action ids and now script working without any problems. I can't say why it not working when i'm using unique ids. But i can say if you using actions ids it working good.
 

Similar threads

Back
Top