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

Help, low level death protection

KrychaXX

New Member
Joined
Apr 22, 2008
Messages
91
Reaction score
0
Help. I have TFS 0.3.6 and this script:http://otland.net/f82/low-level-death-protection-39020/

And i ded, HP dont recover, still on temple with 0 HP and high effects

Screen:
beztytuu2az.jpg


Sorry with my english :/

Script:
PHP:
local config = {
    deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
    sqlType = getConfigInfo('sqlType'),
    maxDeathRecords = getConfigInfo('maxDeathRecords'),
    deadProtection = getConfigInfo('deadProtection')
}
config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    if(isPlayer(cid))then
        if(math.abs(config.deadProtection) >= getPlayerLevel(cid))then
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
            doCreatureAddMana(cid, (getCreatureMaxMana(cid) - getCreatureMana(cid)))
            doSendMagicEffect(getCreaturePosition(cid), 37)
            doRemoveCondition(cid, CONDITION_INFIGHT)
        else
            if(config.deathListEnabled ~= TRUE) then
                return TRUE
            end

            local hitKillerName = "field item"
            local damageKillerName = ""
            if(lastHitKiller ~= FALSE) then
                if(isPlayer(lastHitKiller) == TRUE) then
                    hitKillerName = getPlayerGUID(lastHitKiller)
                else
                    hitKillerName = getCreatureName(lastHitKiller)
                end

                if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
                    if(isPlayer(mostDamageKiller) == TRUE) then
                        damageKillerName = getPlayerGUID(mostDamageKiller)
                    else
                        damageKillerName = getCreatureName(mostDamageKiller)
                    end
                end
            end
            db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
            local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
            if(rows:getID() ~= -1) then
                local amount = rows:getRows(true) - config.maxDeathRecords
                if(amount > 0) then
                    if(config.sqlType == DATABASE_ENGINE_SQLITE) then
                        for i = 1, amount do
                        db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
                        end
                    else
                    db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
                    end
                end
            end
            return TRUE
        end
    end
end

In logs i have only this:
[Warning - Groups::getGroup] Group 0 not found.
[Warning - Groups::getGroup] Group 0 not found.
 
@ ENG
Go make in mysql group "0"
Go on mysql -> phpmyadmin -> log in -> select your database name, click on "groups" -> add group -> ID: 0 , Name: Player


@ PL
Stwórz Grupe "0" w PhpMyAdmin w twojej bazie danych.
Wejdź: mysql -> phpmyadmin -> zaloguj sie -> w menu po lewej masz bazy danych, wybierz swoją dalej będziesz miał zakładke "Groups" wejdź w nią -> dodaj grupe -> ID: 0 , Name: Player


Check this script:
PHP:
local config = {
    deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
    sqlType = getConfigInfo('sqlType'),
    maxDeathRecords = getConfigInfo('maxDeathRecords'),
    deadProtection = getConfigInfo('deadProtection')
}
config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    if(isPlayer(cid))then
        if(math.abs(config.deadProtection) >= getPlayerLevel(cid))then
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            doPlayerAddHealth(cid,getCreatureMaxHealth(cid))
            doPlayerAddMana(cid,getCreatureMaxMana(cid))
            doSendMagicEffect(getCreaturePosition(cid), 37)
            doRemoveCondition(cid, CONDITION_INFIGHT)
        else
            if(config.deathListEnabled ~= TRUE) then
                return TRUE
            end

            local hitKillerName = "field item"
            local damageKillerName = ""
            if(lastHitKiller ~= FALSE) then
                if(isPlayer(lastHitKiller) == TRUE) then
                    hitKillerName = getPlayerGUID(lastHitKiller)
                else
                    hitKillerName = getCreatureName(lastHitKiller)
                end

                if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
                    if(isPlayer(mostDamageKiller) == TRUE) then
                        damageKillerName = getPlayerGUID(mostDamageKiller)
                    else
                        damageKillerName = getCreatureName(mostDamageKiller)
                    end
                end
            end
            db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
            local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
            if(rows:getID() ~= -1) then
                local amount = rows:getRows(true) - config.maxDeathRecords
                if(amount > 0) then
                    if(config.sqlType == DATABASE_ENGINE_SQLITE) then
                        for i = 1, amount do
                        db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
                        end
                    else
                    db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
                    end
                end
            end
            return TRUE
        end
    end
end

Hope, I'll help.
Fresh.​
 
Last edited:
Back
Top