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

TFS 1.X+ Ghost

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
549
Solutions
32
Reaction score
307
Location
Poland
GitHub
AscuasFunkeln
Anyone have idea how to fix that? Ghost for certain time. Idea is just recast after 3 sec function...
LUA:
function addInvisible(player)
        addEvent(stopInvisible, 3000, player.uid)
    local isGhost = not player:isInGhostMode()
    player:setGhostMode(isGhost)
    if isGhost then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now invisible.")
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are visible again.")
    end
    return false
end

--THIS FK PART DONT WORK \/ --
-- After 3 second delay from addevent, function stopInvisible start and return error "attempt to index local 'player' (a number value).
function stopInvisible(player)
    local isGhost = not player:isInGhostMode()
    player:setGhostMode(isGhost)
    if isGhost then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now invisible.")
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are visible again.")
    end
    return false
end

function onCastSpell(player)
   return addInvisible(player)
end
 
Solution
LUA:
local function toggleGhost(cid)
    local player = Player(cid)
    if not player then
        return
    end
    local newGhostMode = not player:isInGhostMode()
    player:setGhostMode(newGhostMode)
    if newGhostMode then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now invisible.")
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are visible again.")
    end
end

function onCastSpell(player)
    local cid = player:getId()
    toggleGhost(cid)
    addEvent(toggleGhost, 3000, cid)
end
LUA:
local function toggleGhost(cid)
    local player = Player(cid)
    if not player then
        return
    end
    local newGhostMode = not player:isInGhostMode()
    player:setGhostMode(newGhostMode)
    if newGhostMode then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now invisible.")
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are visible again.")
    end
end

function onCastSpell(player)
    local cid = player:getId()
    toggleGhost(cid)
    addEvent(toggleGhost, 3000, cid)
end
 
Solution
Back
Top