function onKill(cid, target)
local frags = getPlayerFrags(cid)
if(isPlayer(cid) and isPlayer(target)) then
doBroadcastMessage(getCreatureName(target) .. " was killed by " .. getCreatureName(cid), MESSAGE_STATUS_WARNING)
doPlayerAddItem(cid, 2148, (frags > 0 and (frags * 2) or 2))
end
return true
end
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/pk.lua:onKill
data/creaturescripts/scripts/pk.lua:4: attempt to call global 'getPlayerFrags' (
a nil value)
stack traceback:
data/creaturescripts/scripts/pk.lua:4: in function <data/creaturescripts
/scripts/pk.lua:1>
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/pk.lua:onKill
data/creaturescripts/scripts/pk.lua:2: attempt to call global 'getPlayerFrags' (a nil value)
stack traceback:
data/creaturescripts/scripts/pk.lua:2: in function <data/creaturescripts/scripts/pk.lua:1>
local gold = 2152
function onKill(cid, target, lastHit)
if isPlayer(cid) and isPlayer(target) and lastHit then
if getPlayerIp(cid) ~= getPlayerIp(target) then
doPlayerAddItem(cid, gold, 1)
end
end
return true
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