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

Help with a function for my war server

CipsoftStinks

www.relicaria.com
Joined
Oct 1, 2016
Messages
946
Solutions
3
Reaction score
138
Location
Argentina
Hello i have source edit my ot to make it war server
i followed this thread Feature - Every changes you need to a Hardcore/War Server

for the skull system i use this mod :
LUA:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Skull System" version="1.0" author="Skyforever" contact="tibiaking.com" enabled="yes">
<config name="SkullC_func"><![CDATA[

function setSkullColor(cid)
local t = {
[{1,2}] = 1,
[{3,4}] = 2,
[{5,6}] = 3,
[{7,math.huge}] = 4
}
for var, ret in pairs(t) do
if getPlayerFrags(cid) >= var[1] and getPlayerFrags(cid) <= var[2] then
doCreatureSetSkullType(cid, ret)
end
end
end
function getPlayerFrags(cid)
local time = os.time()
local times = {today = (time - 86400), week = (time - (7 * 86400))}
local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
if(result:getID() ~= -1) then
repeat
local content = {date = result:getDataInt("date")}
if(content.date > times.today) then
table.insert(contents.day, content)
elseif(content.date > times.week) then
table.insert(contents.week, content)
else
table.insert(contents.month, content)
end
until not result:next()
result:free()
end
local size = {day = table.maxn(contents.day),week = table.maxn(contents.week),month = table.maxn(contents.month)}
return size.day + size.week + size.month
end
]]></config>
<event type="login" name="SkullLogin" event="script"><![CDATA[
domodlib('SkullC_func')
function onLogin(cid)
registerCreatureEvent(cid, "ColorKill")
setSkullColor(cid)
return true
end]]></event>
<event type="kill" name="ColorKill" event="script"><![CDATA[
domodlib('SkullC_func')
function onKill(cid, target)
if isPlayer(cid) and isPlayer(target) then
doCreatureSetSkullType(target, 0)
addEvent(setSkullColor, 100, cid)
end
return true
end]]></event>
</mod>

the problem is that the skull won by the players , is never lost..
what i can do to make posible to lost it when player die?
please some help
regards
 
Your system will add the skull type based on how many frags a player has, based on the function setSkullColor() that's excuted onLogin and after each onKill.

If you want to change that so everytime someone dies they lose their skull (aka start over) then you have to remove the players frags when he's killed as well, which you can edit in your onKill function. (you can search for any frag-remover script to see how to do it)

--------------------------------
If you don't want to remove everyone's frags and you just want to reset the skull on each death then I would instead add the skull based off of a storage that increases everytime you get a kill. But when you die it's set to 0. That way it will restart on each death and their over-all frags are not erased.

XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Skull System" version="1.0" author="Skyforever" contact="tibiaking.com" enabled="yes">
<config name="SkullC_func"><![CDATA[
function setSkullColor(cid)
    local t = {
        [{1,2}] = 1,
        [{3,4}] = 2,
        [{5,6}] = 3,
        [{7,math.huge}] = 4
    }
    for var, ret in pairs(t) do
        if getPlayerFragsToday(cid) >= var[1] and getPlayerFragsToday(cid) <= var[2] then
            doCreatureSetSkullType(cid, ret)
        end
    end
end
function getPlayerFrags(cid)
    return math.max(0, getCreatureStorage(cid, 12345))
end
]]></config>
<event type="login" name="SkullLogin" event="script"><![CDATA[
domodlib('SkullC_func')
function onLogin(cid)
    registerCreatureEvent(cid, "ColorKill")
    setSkullColor(cid)
return true
end
]]></event>
<event type="kill" name="ColorKill" event="script"><![CDATA[
domodlib('SkullC_func')
function onKill(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        doCreatureSetStorage(target, 12345, 0) -- target frag counter set to 0
        doCreatureSetStorage(cid, 12345, (math.max(0, getCreatureStorage(cid, 12345)) + 1)) -- killer gets frag = frags + 1
        doCreatureSetSkullType(target, 0)
        addEvent(setSkullColor, 100, cid)
    end
return true
end
]]></event>
</mod>
 
Your system will add the skull type based on how many frags a player has, based on the function setSkullColor() that's excuted onLogin and after each onKill.

If you want to change that so everytime someone dies they lose their skull (aka start over) then you have to remove the players frags when he's killed as well, which you can edit in your onKill function. (you can search for any frag-remover script to see how to do it)

--------------------------------
If you don't want to remove everyone's frags and you just want to reset the skull on each death then I would instead add the skull based off of a storage that increases everytime you get a kill. But when you die it's set to 0. That way it will restart on each death and their over-all frags are not erased.

XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Skull System" version="1.0" author="Skyforever" contact="tibiaking.com" enabled="yes">
<config name="SkullC_func"><![CDATA[
function setSkullColor(cid)
    local t = {
        [{1,2}] = 1,
        [{3,4}] = 2,
        [{5,6}] = 3,
        [{7,math.huge}] = 4
    }
    for var, ret in pairs(t) do
        if getPlayerFragsToday(cid) >= var[1] and getPlayerFragsToday(cid) <= var[2] then
            doCreatureSetSkullType(cid, ret)
        end
    end
end
function getPlayerFrags(cid)
    return math.max(0, getCreatureStorage(cid, 12345))
end
]]></config>
<event type="login" name="SkullLogin" event="script"><![CDATA[
domodlib('SkullC_func')
function onLogin(cid)
    registerCreatureEvent(cid, "ColorKill")
    setSkullColor(cid)
return true
end
]]></event>
<event type="kill" name="ColorKill" event="script"><![CDATA[
domodlib('SkullC_func')
function onKill(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        doCreatureSetStorage(target, 12345, 0) -- target frag counter set to 0
        doCreatureSetStorage(cid, 12345, (math.max(0, getCreatureStorage(cid, 12345)) + 1)) -- killer gets frag = frags + 1
        doCreatureSetSkullType(target, 0)
        addEvent(setSkullColor, 100, cid)
    end
return true
end
]]></event>
</mod>
thanks i change my mod for your mod. but im having a trouble , i need to edit some scprit or add some in creature events?
im not scripter but can you guide me? i know how search :)
thanks for your feedback bro im very happy
 
Back
Top