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

Is it possible to make an own protection system on TFS 0.3.6?

Erevius

It Was A Good Day
Joined
Feb 12, 2010
Messages
157
Reaction score
7
Location
Poland/Olsztyn
Hello. I would like to make my own protection system on my OTS. I mean, a player, f.e. lvl 20, may attack players with 15lvl or higher and cannot be attacked by players higher than 30lvl. It was only an example, I just need to know if it's possible to make something like that by lua scritps? If not, then maybe someone could write a C++ script? it think its a good idea for RPG ots... What do you think?

PS: if there's any misstake, sorry for my english (correct me please)

#down
well, I couldn't find it anywhere...
damn, you were right dude!
Code:
--LEVEL_THRESHOLD is how many levels your victim can be away from your own level
--Example: Threshold of 10 means a player with level 100 can people at level 90 to level 110
local LEVEL_THRESHOLD = 10
 
local function isPlayerAboveThreshold(cid, target)
 
    -- This makes sure we are only processing statchanges made by PvP
    if(isPlayer(target))then
 
        -- We need to get the players levels of course
        local attackerLvl, targetLvl = getPlayerLevel(cid), getPlayerLevel(target)
 
        -- Now we shall check the actual threshold vs. the ideal one
        if(math.abs(attackerLvl - targetLvl) &gt LEVEL_THRESHOLD)then
 
            -- OMG it's above the limit! We shall report back with what we found!
            return true
 
        end
    end
 
    -- At least one condition was not met. We shall say false!
    return false
end
 
function onStatsChange(cid, attacker, type, combat, value)
    if(isPlayerAboveThreshold(attacker, cid))then
        return false
    end
    return true
end
 
function onTarget(cid, target)
    if(isPlayerAboveThreshold(cid, target))then
        return false
    end
    return true
end
 
Last edited:
Back
Top