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

RevScripts when player get first time level x, tp player with motd ask

Lbtg

Advanced OT User
Joined
Nov 22, 2008
Messages
2,394
Reaction score
162
Hey, i would like to ask for help for such thingy/idea:

Revscript
tfs 1.4++

If player first time get level 22, he gets a motd ''You reached 50 level, now you can be teleported to xx if you want to ?'' And player can choose 'teleport me' and it will teleport player to x/y/z, if player choose button ''cancel teleportation'' it wont teleport player. This thingy shoud appear only one time on reach of lvl 22, so it wont repeat.

I hope i explained it understandaible and someone can help with this
 
Hey, i would like to ask for help for such thingy/idea:

Revscript
tfs 1.4++

If player first time get level 22, he gets a motd ''You reached 50 level, now you can be teleported to xx if you want to ?'' And player can choose 'teleport me' and it will teleport player to x/y/z, if player choose button ''cancel teleportation'' it wont teleport player. This thingy shoud appear only one time on reach of lvl 22, so it wont repeat.

I hope i explained it understandaible and someone can help with this

My first ever attempt to modal windows, for learning purposes, hope it works as you expected.

LUA:
local teleportPosition = Position(2006, 1324, 7)
local storageId = 987654

local levelTwentyTwo = CreatureEvent("levelTwentyTwo")

function levelTwentyTwo.onAdvance(player, skill, oldLevel, newLevel)

    local storedValue = player:getStorageValue(storageId)
    if storedValue == 1 then
        return true
    end

    player:registerEvent("levelTwentyTwo_Modal")
    if newLevel >= 22 then      
        player:setStorageValue(storageId, 1)
        local title = "Teleport?"
        local message = "Do you want to be teleported?"
    
        local window = ModalWindow(1002, title, message)
      
        window:addButton(100, "Yes")
        window:addButton(101, "No")
      
        window:setDefaultEnterButton(100)
        window:setDefaultEscapeButton(101)
      
        window:sendToPlayer(player)
    end
    return true
end

levelTwentyTwo:register()

local levelTwentyTwo_Modal = CreatureEvent("levelTwentyTwo_Modal")

function levelTwentyTwo_Modal.onModalWindow(player, modalWindowId, buttonId, choiceId)
    if modalWindowId == 1002 then
        if buttonId == 100 then
            player:teleportTo(teleportPosition)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have been teleported.")
        elseif buttonId == 101 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "Teleportation cancelled.")
        end
    end
    player:unregisterEvent("levelTwentyTwo_Modal")
    return true
end

levelTwentyTwo_Modal:register()
 
Last edited:

Similar threads

Back
Top