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

Windows How to fix free mounts for every player / Addons ?

Zoriax_

Owner|Antarctica Ots
Joined
Feb 15, 2008
Messages
745
Reaction score
23
Location
Norway
How can i fix so every players get free mounts, right when they login to the server?
 
Solution
add this to your player.lua in your lib folder
Lua:
local match = string.match
local find = string.find
local gsub = string.gsub
local tonumber = tonumber
local hasOutfit = Player.hasOutfit

function Player.getUnownedOutfits(self)
    local outfits = table.create(200, 0)
    local sexPattern = 'type="'..self:getSex()..'"'
    local lookPattern = 'looktype="(%d*)"'
    local file = io.open([[data/xml/outfits.xml]])
    local str = file:read("*a")
    local i, j = find(str, sexPattern)
    file:close()
    while (i and j) do
        local _i, _j = find(str, sexPattern, j)
        local looktype = tonumber(match(str, lookPattern, i))
        for addon = 3, 1, -1 do
            if not hasOutfit(player, looktype, addon) then...
Basically, you just add each mount to the player when they login for the first time.

tfs 0.3.7
Lua:
doPlayerAddMount(cid, mount_id)
 
add this to your player.lua in your lib folder
Lua:
local match = string.match
local find = string.find
local gsub = string.gsub
local tonumber = tonumber
local hasOutfit = Player.hasOutfit

function Player.getUnownedOutfits(self)
    local outfits = table.create(200, 0)
    local sexPattern = 'type="'..self:getSex()..'"'
    local lookPattern = 'looktype="(%d*)"'
    local file = io.open([[data/xml/outfits.xml]])
    local str = file:read("*a")
    local i, j = find(str, sexPattern)
    file:close()
    while (i and j) do
        local _i, _j = find(str, sexPattern, j)
        local looktype = tonumber(match(str, lookPattern, i))
        for addon = 3, 1, -1 do
            if not hasOutfit(player, looktype, addon) then
                outfits[looktype] = addon
                break
            end
        end
        i, j = _i, _j
    end
    return outfits
end
in login.lua under function onLogin(player)
Lua:
if player:getStorageValue(77777) == -1 then
    -- 1 is the starting mount id, 102 is the ending mount id, check mounts.xml for yours
    for i = 1, 102 do
        player:addMount(i)
    end
    for outfit, addon in pairs(player:getUnownedOutfits()) do
        player:addOutfit(outfit, addon)
    end
    player:setStorageValue(77777, 1)
end
 
Last edited:
Solution
Back
Top