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

TalkAction [TFS 1.X] Change world Type (noPvp, pvp, PvpEnfo)

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
I downloaded a base 1.3 and saw that it does not have the script to change the worldType (nopvp, pvp, pvpenfo), so I created this talkaction for 1.x

data/talkactions/talkactions.xml
Code:
<talkaction words="/pvp" separator=" " script="mode.lua" />

data/talkactions/scripts creatre a file with name mode.lua, put it inside:

Lua:
local config = {
    [1] = {"no-pvp", WORLD_TYPE_NO_PVP},
    [2] = {"pvp", WORLD_TYPE_PVP},
    [3] = {"pvp-enforced", WORLD_TYPE_PVP_ENFORCED},
}

function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    local param = tonumber(param)
    local haveConfig = config[param]
    if not param or not haveConfig then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command param required. exemple: /pvp 1, 2 or 3")
        return true
    end

    if haveConfig then
        Game.setWorldType(haveConfig[2])
        Game.broadcastMessage("Gameworld type set to: " .. haveConfig[1] .. ".", MESSAGE_EVENT_ADVANCE)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Gameworld type set to: " .. haveConfig[1] .. ".")
    end
  
    return true
end

Use /pvp 1 to set no-PvP
/pvp 2 to set PvP
/pvp 3 to set PvP Enfo
 
Back
Top