• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua CTF event!!

kleitonalan

New Member
Joined
Mar 21, 2013
Messages
289
Reaction score
3
when the player dies with the flag, it does not change the addon continues with clothing flag? someone could see the script for me?

Code:
function onOutfit(cid, old, current)
    if(getPlayerStorageValue(cid, ctfConfig.playerHasFlag) == 1) then
       return false
    end
  
    local color = TEAMS[CTF_GetPlayerTeam(cid)].COLOR
    if current.lookHead == color[1] and current.lookBody == color[2] and current.lookLegs == color[3] and current.lookFeet == color[4] then
        return true
    end
    return false
end

Code:
function onLogout(cid)
    if getPlayerStorageValue(cid, ctfConfig.playerHasFlag) == 1 then
        local item = doCreateItem(TEAMS[CTF_GetOpponentTeam(cid)].FLAG_POSITION.itemid, 1, TEAMS[CTF_GetOpponentTeam(cid)].FLAG_POSITION.pos)
        if item then
            doItemSetAttribute(item, "uid", TEAMS[CTF_GetOpponentTeam(cid)].FLAG_UID)
        end
        -- cleanup
        setPlayerStorageValue(cid, ctfConfig.playerHasFlag, "0")
        setGlobalStorageValue(ctfConfig.teamHasFlag, "0")
    end
return true
end

Code:
function onPrepareDeath(cid, deathList)
    if getPlayerStorageValue(cid, ctfConfig.playerHasFlag) == 1 then
        local item = doCreateItem(TEAMS[CTF_GetOpponentTeam(cid)].FLAG_POSITION.itemid, 1, TEAMS[CTF_GetOpponentTeam(cid)].FLAG_POSITION.pos)
        if item then
            doItemSetAttribute(item, "uid", TEAMS[CTF_GetOpponentTeam(cid)].FLAG_UID)
        end
        -- cleanup
        setPlayerStorageValue(cid, ctfConfig.playerHasFlag, 0)
        setGlobalStorageValue(ctfConfig.teamHasFlag, 0)
    end
    if isPlayer(cid) then
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
        doTeleportThing(cid, TEAMS[CTF_GetTeam(cid)].SPAWN_POSITION)
        doPlayerSendTextMessage(cid, 22, 'You were killed in CTF Event!')
        return false
    end
return true
end

Code:
function onStatsChange(cid, attacker, type, combat, value)
    --if (CTF_GetPlayerTeam(cid) == CTF_GetPlayerTeam(attacker)) then
    --    return false
    --end
    if (type == STATSCHANGE_HEALTHLOSS) and getCreatureHealth(cid) <= value then
        if getPlayerStorageValue(cid, ctfConfig.playerHasFlag) == 1 then
            local item = doCreateItem(TEAMS[CTF_GetOpponentTeam(cid)].FLAG_POSITION.itemid, 1, TEAMS[CTF_GetOpponentTeam(cid)].FLAG_POSITION.pos)
            if item then
                doItemSetAttribute(item, "uid", TEAMS[CTF_GetOpponentTeam(cid)].FLAG_UID)
            end
            local color = TEAMS[CTF_GetPlayerTeam(cid)].COLOR
            doCreatureChangeOutfit(cid, {lookType = getPlayerSex(cid) == 1 and ctfConfig.maleOutfits[math.random(#ctfConfig.maleOutfits)] or ctfConfig.femaleOutfits[math.random(#ctfConfig.femaleOutfits)], lookHead = color[1], lookBody = color[2], lookLegs = color[3], lookFeet = color[4], lookAddons = math.random(3)})      
            doBroadcastMessage("[ CTF Event ]\n".. CTF_GetTeamName(cid) .." Team killed flag and took it back to camp !")
            -- cleanup
            setPlayerStorageValue(cid, ctfConfig.playerHasFlag, 0)
            setGlobalStorageValue(ctfConfig.teamHasFlag, 0)
        end
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
        doTeleportThing(cid, TEAMS[CTF_GetPlayerTeam(cid)].SPAWN_POSITION)
        doRemoveCondition(cid, CONDITION_INFIGHT)
        doPlayerSendTextMessage(cid, 22, 'You were killed! Wait 5 sec !')
        return false
    end
    return true
end

Code:
function onCombat(cid, target)
    if(CTF_GetPlayerTeam(cid) == CTF_GetPlayerTeam(target)) then
    return false
    end
    return true
end

Code:
-- CtfIdle
local config = {
    idleWarning = 300*1000,
    idleKick = 360*1000
}

function onThink(cid, interval)
    if(getPlayerStorageValue(cid, ctfConfig.playerHasFlag) == 1) then
       return true
    end
  
    local idleTime = getPlayerIdleTime(cid) + interval
    doPlayerSetIdleTime(cid, idleTime)
    if(config.idleKick > 0 and idleTime > config.idleKick) then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        doRemoveCreature(cid)
    elseif(config.idleWarning > 0 and idleTime == config.idleWarning) then
        local message = "You have been idle for " .. math.ceil(config.idleWarning / 1000) .. " seconds"
        if(config.idleKick > 0) then
            message = message .. ", you will be disconnected in "
            local diff = math.ceil((config.idleWarning - config.idleKick) / 1000)
            if(diff > 1) then
                message = message .. diff .. " seconds"
            else
                message = message .. "one minute"
            end

            message = message .. " if you are still idle on CTF"
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, message .. ".")
    end
    return true
end

anyone? to help me?
Sorry double post.
 
Last edited by a moderator:
Couldn't Understand what is your problem.Please explain more and be clear and post what tfs you are using and if possible screenshot
 
Ok. Moment.

upload_2014-2-23_21-1-39.png


the player died with the enemy flag, so that after death he will not back the clothes he was before he gets the flag clothing. he was right back to normal after die. TFS 0.4 rev 3777.19
 
Last edited by a moderator:
Back
Top