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

Solved (Tfs 1.1) Refresh characters

Apollos

Dude who does stuff
Joined
Apr 22, 2009
Messages
829
Solutions
123
Reaction score
655
Location
United States
Have an event in the making where I use Game.setWorldType to change to pvp enforced and then change back to pvp, the problem is if you have a red skull before the event starts you will keep it until you change floors, and same issue when the event ends. Wondering if there is a way to refresh the character, I was thinking of doing setSkull(getSkull) or something but I'm not sure if that would be too much for the server or not.
 
Solution
Ended up doing this:
Lua:
function refreshSkull()
    local players = Game.getPlayers()
    for i = 1, #players do
        local playersPos = players[i]:getPosition()
        local playersDir = players[i]:getDirection()
        players[i]:teleportTo(Position(997, 901, 7))
        players[i]:teleportTo(playersPos)
        players[i]:setDirection(playersDir)
    end
end

Hope this one's good, thanks for the help.
lua is very fast, you never have to worry about performance really
just run a loop to set player skulls from red to none after you set world type
 
Maybe you should just prevent people with red skulls from entering the event?
Why reward the destructive?
 
Well I tried to do the setSkull deal like this:
Lua:
function setEventSkull()
    local players = Game.getPlayers()
    for i = 1, #players do
        players[i]:setSkull(SKULL_NONE)
    end
end

function setNormalSkull()
    local players = Game.getPlayers()
    for i = 1, #players do
        players[i]:setSkull(players[i]:getSkull())
    end
end

No errors and seemed to work but it basically saves the character as SKULL_NONE until the character kills another person. I guess I could have it check the players frags but before without doing anything with setSkull it would return to its original skull after the event was over but it was only when you go up or downstairs. Not sure what's happening, I'm assuming its a function of that happens with onfloorchange or something? I've been looking through source code and haven't come across anything yet.

@Codex NG Any other time I would agree but with this event I'm kinda hoping for more destruction.
 
Ended up doing this:
Lua:
function refreshSkull()
    local players = Game.getPlayers()
    for i = 1, #players do
        local playersPos = players[i]:getPosition()
        local playersDir = players[i]:getDirection()
        players[i]:teleportTo(Position(997, 901, 7))
        players[i]:teleportTo(playersPos)
        players[i]:setDirection(playersDir)
    end
end

Hope this one's good, thanks for the help.
 
Solution
Back
Top