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

Lua TFS 1.0 change outfit or colors

narko

vertrauenswürdig ~
Joined
Oct 19, 2008
Messages
1,317
Solutions
2
Reaction score
132
Location
Unknown
I'm looking for a script that doesn't allow the players to change their outfits or colors while they're on an event or if they do have a storage.

If someone has done this already for 1.0, could you please share it?
 
I've tried with this lines from events/creature.lua:

Code:
function Creature:onChangeOutfit(outfit)
local player = Player(cid)
      if(player:getStorageValue(33165) == 1) then
            if player:getGroup() > 3 then
                return true
            end
            if player:getStorageValue(33169) == 0 then
                if player:getStorageValue(5447) > -1 then
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot change your outfit during the event.")
                    return false
                end
            end
        end
        return true
    end

Getting this as error:
data/events/scripts/creature.lua:Creature@onChangeOutfit
data/events/scripts/creature.lua:3: attempt to index local 'player' (a nil value)
 
Use self instead of player, so remove local player = Player(cid) and change player to self.
Also check if self is a player: if self:isPlayer() then
 
Last edited:
Code:
function Creature:onChangeOutfit(outfit)
      if(self:getStorageValue(33165) == 1) then
            if self:getGroup() > 3 then
                return true
            end
            if self:getStorageValue(33169) == 0 then
                if self:getStorageValue(5447) > -1 then
                    self:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot change your outfit during the event.")
                    return false
                end
            end
        end
        return true
    end

No errors, but the outfit still can be changed. @Limos
 
Debug it and see:

Code:
function Creature:onChangeOutfit(outfit)
    local getStorage = Player.getStorageValue
    if getStorage(self, 33165) == 1 then
        print("Player has storage: 33165")
        if self:getGroup():getAccess() then
            print("Player is a staff member.")
            return true
        end
       
        print("Player is not staff member.")
        if getStorage(self, 33169) <= 0 then
            print("Player has not storage: 33169")
            if getStorage(self, 5447) > 0 then
                print("Player has storage: 5447")
                self:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot change your outfit during the event.")
                return false
            end
        end
    end

    return true
end
 
Back
Top