Hello lovely OTLanders,
I implemented a new frag system on my sources a few days ago, it should work like it does on Avesta (Instead of saving frags by Day, Week and Month, it counts a frag, then releases through "timeToDecreaseFrags" and yea, thats it).
The source edit was successful and it is working (counting and decreasing frags). It can just not be shown ingame. Unfortunatelly the repository with the code I implemented on my server had no functions.lua and no frags.lua talkacion, and I've been looking for days without a success to find something that will actually work.
Enough talk, here are my scripts, I hope you guys can help me.
data/functions.lua
data/talkactions/scripts/frags.lua
If you see it right, there are a few commented lines, I've been testing without success - I'm not good with queries & lua.
A note: the functions.lua getPlayerFrags(cid) worked with the unedited sources (days, weeks, months), so It probably fetches the kill from the right place on my Database, this could help, now that's all I know, I'm helpless.
Thank you in advance and the kindest Regards,
Okke.
I implemented a new frag system on my sources a few days ago, it should work like it does on Avesta (Instead of saving frags by Day, Week and Month, it counts a frag, then releases through "timeToDecreaseFrags" and yea, thats it).
The source edit was successful and it is working (counting and decreasing frags). It can just not be shown ingame. Unfortunatelly the repository with the code I implemented on my server had no functions.lua and no frags.lua talkacion, and I've been looking for days without a success to find something that will actually work.
Enough talk, here are my scripts, I hope you guys can help me.
data/functions.lua
Code:
function getPlayerFrags(cid)
local time = os.time()
local times = {today = (time - 86400), week = (time - (7 * 86400))}
--OLD--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")
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 `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
data/talkactions/scripts/frags.lua
Code:
local config = {
fragTime = getConfigInfo('timeToDecreaseFrags')
}
function onSay(cid, words, param)
local amount = getPlayerFrags(cid)
--if(amount > 0 and config.fragTime > 0) then
if(getPlayerFrags(cid) > 0 and config.fragTime > 0) then
local frags = math.floor((amount / config.fragTime) + 1)
local remainingTime = math.floor(amount - (config.fragTime * (frags - 1)))
local hours = math.floor(((remainingTime / 1000) / 60) / 60)
local minutes = math.floor(((remainingTime / 1000) / 60) - (hours * 60))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have " .. frags .. " unjustified frag" .. (frags > 2 and "s" or "") .. ". The amount of unjustified frags will decrease after: " .. hours .. "h and " .. minutes .. "m.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have any unjustified frag.")
end
return false
end
If you see it right, there are a few commented lines, I've been testing without success - I'm not good with queries & lua.
A note: the functions.lua getPlayerFrags(cid) worked with the unedited sources (days, weeks, months), so It probably fetches the kill from the right place on my Database, this could help, now that's all I know, I'm helpless.
Thank you in advance and the kindest Regards,
Okke.