function onKill(cid, target)
local amount = getPlayerRedSkullTicks(cid)
local frags = math.floor((amount / config.fragTime) + 1)
if isPlayer(target) == TRUE and frags % 5 == 0 then
broadcastMessage(getCreatureName(cid) .. " has now ".. frags.." frag" .. (frags > 2 and "s." or ".") ...,MESSAGE_STATUS_WARNING)
end
return TRUE
end
function onKill(cid, target)
local amount = getPlayerRedSkullTicks(cid)
local frags = math.floor((amount / config.fragTime) + 1)
if isPlayer(target) == TRUE and frags == 5 or frags == 10 or frags == 15 or frags == 20 or frags == 25 then
broadcastMessage(getCreatureName(cid) .. " has now ".. frags.." frag" .. (frags > 2 and "s." or ".") ...,MESSAGE_STATUS_WARNING)
end
return TRUE
end
function onKill(cid, target)
local kills = getPlayerFrags(cid)
if(isPlayer(target))
if(kills == 5 or kills = 10 or kills == 15 or kills == 20) then
broadcastMessage(getCreatureName(cid) .." have reached ".. kills .." kills! Dont let him get more!",MESSAGE_STATUS_WARNING)
end
end
return true
end
Old thread but maybeAlso put in creaturescript, dont forget to registerEvent in login.lua.LUA:function onKill(cid, target) local kills = getPlayerFrags(cid) if(isPlayer(target)) if(kills == 5 or kills = 10 or kills == 15 or kills == 20) then broadcastMessage(getCreatureName(cid) .." have reached ".. kills .." kills! Dont let him get more!",MESSAGE_STATUS_WARNING) end end return true end
[02/01/2010 08:04:27] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/frags.lua:4: 'then' expected near 'if'
[02/01/2010 08:04:27] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/frags.lua)
[02/01/2010 08:04:27] data/creaturescripts/scripts/frags.lua:4: 'then' expected near 'if'
function onKill(cid, target)
local kills = getPlayerFrags(cid)
if(isPlayer(target))then
if(kills == 5 or kills == 10 or kills == 15 or kills == 20) then
broadcastMessage(getCreatureName(cid) .." have reached ".. kills .." kills! Dont let him get more!",MESSAGE_STATUS_WARNING)
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
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
function onKill(cid, target)
local kills = getPlayerFrags(cid)
if(isPlayer(target))then
if(kills == 5 or kills == 10 or kills == 15 or kills == 20) then
broadcastMessage(getCreatureName(cid) .." have reached ".. kills .." kills! Dont let him get more!",MESSAGE_STATUS_WARNING)
end
end
return true
function onKill(cid, target)
local amount = getPlayerRedSkullTicks(cid)
local frags = math.floor((amount / config.fragTime) + 1)
if isPlayer(target) == TRUE and frags % 5 == 0 then
broadcastMessage(getCreatureName(cid) .. " has now ".. frags.." frag" .. (frags > 2 and "s." or ".") ...,MESSAGE_STATUS_WARNING)
end
return TRUE
end