Hello, I've got an OT war server (version 8.6 TFS 0.4), and I have implemented this skull system mod:
The code goes well, the problem is that the kills that trigger this mod are those for the frags that only YOU have done and not with "assistance" when someone dies.
Why is this a problem? because I have a look system that shows all the kills, either assistance or yours, making it not fit the kills when you look someone and the frags that really count for getting the skulls ( I don't know if I'm explaining it right, for example, I've got a yellow skull but the frags that people see on me are more than 100 and I have only 60) .
This is the code:
It occurs to me do 2 things:
1. Make the MOD count the total frags, either assistance or own (IDEAL)
2. Make the frag look system only show their own kills.
If anyone would bother to help me out ill really appreciate it with a good + rep
PS: Thanks to Skyforever and Vodka for the scripts
Greetings from Chile!
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<modname="Skull System"version="1.0"author="Skyforever"contact="*********.com"enabled="yes">
<configname="SkullC_func"><![CDATA[
function setSkullColor(cid)
local t = {
[{50,100}] = 1,
[{101,150}] = 2,
[{151,200}] = 3,
[{201,350}] = 4,
[{351,math.huge}] = 5
}
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>
<eventtype="login"name="SkullLogin"event="script"><![CDATA[
domodlib('SkullC_func')
function onLogin(cid)
registerCreatureEvent(cid, "ColorKill")
setSkullColor(cid)
return true
end]]></event>
<eventtype="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 code goes well, the problem is that the kills that trigger this mod are those for the frags that only YOU have done and not with "assistance" when someone dies.
Why is this a problem? because I have a look system that shows all the kills, either assistance or yours, making it not fit the kills when you look someone and the frags that really count for getting the skulls ( I don't know if I'm explaining it right, for example, I've got a yellow skull but the frags that people see on me are more than 100 and I have only 60) .
This is the code:
Code:
function onLook(cid, thing, position, lookDistance)
function getDeathsAndKills(cid, type) -- by vodka
local query,d = db.getResult("SELECT `player_id` FROM "..(tostring(type) == "kill" and "`player_killers`" or "`player_deaths`").." WHERE `player_id` = "..getPlayerGUID(cid)),0
if (query:getID() ~= -1) then
repeat
d = d+1
until not query:next()
query:free()
end
return d
end
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, "\n"..(getPlayerSex(thing.uid) == 0 and "She" or "He").." has Killed: ["..getDeathsAndKills(thing.uid, "kill").."] Players.\n"..(getPlayerSex(thing.uid) == 0 and "She" or "He").." has Died: ["..getDeathsAndKills(thing.uid, "death").."] Times")
end
return true
end
It occurs to me do 2 things:
1. Make the MOD count the total frags, either assistance or own (IDEAL)
2. Make the frag look system only show their own kills.
If anyone would bother to help me out ill really appreciate it with a good + rep
PS: Thanks to Skyforever and Vodka for the scripts
Greetings from Chile!
Last edited: