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

mondal

theduck

Member
Joined
Dec 6, 2018
Messages
246
Reaction score
20
Code:
local stats = {
    [1] = {name = 'test 1'},
    [2] = {name = 'test 2'}
}

function onSay(player, words, param)


   
    local window = ModalWindow { title = 'welcome', message = 'test' }
  
    for i = 1, #stats do
        window:addChoice(stats.name)
    end

    window:addButton('Okey', ( 
    
            function(button, choice)
            
              if choice.id == 1 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss.")
              end
               
               if choice.id == 2 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss")
              end

            end
        )
    )
    window:setDefaultEnterButton('Okey')
    window:addButton('Close')
    window:setDefaultEscapeButton('Close')
    window:sendToPlayer(player)
    return false
end

I have a doubt I would like that every time I choose an option it always comes back to the initial january only comes out when the player clicks the exit
 
Solution
Do you mean send same window again? Just add code to send window in callback.
Code:
local stats = {
    [1] = {name = 'test 1'},
    [2] = {name = 'test 2'}
}

function onSay(player, words, param)


   
    local window = ModalWindow { title = 'welcome', message = 'test' }
  
    for i = 1, #stats do
        window:addChoice(stats.name)
    end

    window:addButton('Okey', ( 
    
            function(button, choice)
            
              if choice.id == 1 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss.")
              end
               
               if choice.id == 2 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss")
              end...
Do you mean send same window again? Just add code to send window in callback.
Code:
local stats = {
    [1] = {name = 'test 1'},
    [2] = {name = 'test 2'}
}

function onSay(player, words, param)


   
    local window = ModalWindow { title = 'welcome', message = 'test' }
  
    for i = 1, #stats do
        window:addChoice(stats.name)
    end

    window:addButton('Okey', ( 
    
            function(button, choice)
            
              if choice.id == 1 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss.")
              end
               
               if choice.id == 2 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss")
              end
              window:sendToPlayer(player)

            end
        )
    )
    window:setDefaultEnterButton('Okey')
    window:addButton('Close')
    window:setDefaultEscapeButton('Close')
    window:sendToPlayer(player)
    return false
end
I'm not sure what you are asking for. What is 'january'? Looks like google translate bug.
 
Solution
Do you mean send same window again? Just add code to send window in callback.
Code:
local stats = {
    [1] = {name = 'test 1'},
    [2] = {name = 'test 2'}
}

function onSay(player, words, param)


   
    local window = ModalWindow { title = 'welcome', message = 'test' }
  
    for i = 1, #stats do
        window:addChoice(stats.name)
    end

    window:addButton('Okey', ( 
    
            function(button, choice)
            
              if choice.id == 1 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss.")
              end
               
               if choice.id == 2 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss")
              end
              window:sendToPlayer(player)

            end
        )
    )
    window:setDefaultEnterButton('Okey')
    window:addButton('Close')
    window:setDefaultEscapeButton('Close')
    window:sendToPlayer(player)
    return false
end
I'm not sure what you are asking for. What is 'january'? Looks like google translate bug.
yes the translator bugged haha.
that was it! thank you
 
Last edited:
@Gesior.pl
a doubt I changed from onsay to onlogin with the player can no longer log into the server is it possible to make this window appear when the player enters the game?
 
@Gesior.pl
a doubt I changed from onsay to onlogin with the player can no longer log into the server is it possible to make this window appear when the player enters the game?
You need to send it to player with some delay. Client expects first packet from server to be 'login information', not modal and that's why it fails to login probably.
Lua:
local stats = {
    [1] = {name = 'test 1'},
    [2] = {name = 'test 2'}
}

function sendWindowToPlayerOnLogin(cid)
    -- convert 'cid' to 'player' again, it may fail if player get kicked/killed in meantime
    local player = Player(cid)
    if not player then
        return
    end

    local window = ModalWindow { title = 'welcome', message = 'test' }
  
    for i = 1, #stats do
        window:addChoice(stats.name)
    end

    window:addButton('Okey', ( 
    
            function(button, choice)
            
              if choice.id == 1 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss.")
              end
               
               if choice.id == 2 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss")
              end
              window:sendToPlayer(player)

            end
        )
    )
    window:setDefaultEnterButton('Okey')
    window:addButton('Close')
    window:setDefaultEscapeButton('Close')
    window:sendToPlayer(player)
    return false
end


function onLogin(player)
    -- call function that will show window after 100 miliseconds (0.1 sec), pass player id as parameter to that function
    addEvent(sendWindowToPlayerOnLogin, 100, player:getId())
    return true
end
 
You need to send it to player with some delay. Client expects first packet from server to be 'login information', not modal and that's why it fails to login probably.
Lua:
local stats = {
    [1] = {name = 'test 1'},
    [2] = {name = 'test 2'}
}

function sendWindowToPlayerOnLogin(cid)
    -- convert 'cid' to 'player' again, it may fail if player get kicked/killed in meantime
    local player = Player(cid)
    if not player then
        return
    end

    local window = ModalWindow { title = 'welcome', message = 'test' }
 
    for i = 1, #stats do
        window:addChoice(stats.name)
    end

    window:addButton('Okey', (
   
            function(button, choice)
           
              if choice.id == 1 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss.")
              end
              
               if choice.id == 2 then
                   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "ssss")
              end
              window:sendToPlayer(player)

            end
        )
    )
    window:setDefaultEnterButton('Okey')
    window:addButton('Close')
    window:setDefaultEscapeButton('Close')
    window:sendToPlayer(player)
    return false
end


function onLogin(player)
    -- call function that will show window after 100 miliseconds (0.1 sec), pass player id as parameter to that function
    addEvent(sendWindowToPlayerOnLogin, 100, player:getId())
    return true
end
the information worked more
test 1
test 2
is appearing as nill
 
Back
Top