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

[REQUEST] BroadCast Frag!

Nux

Yzeria Custom War
Joined
Jan 2, 2009
Messages
1,067
Reaction score
1
BroadCast Frag!

For example [Name] Has 12 Frags..
 
Solution
Dunno why you bumped this, but anyway!
LUA:
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
First It Broadcasts when someone gets Frag 5, and next time it broad cast is when the player have 8 frags, and next time 11. .. 15 .. 18 .. 21.. etc..
 
Well i want that it broadcasts how much frags player have...
and yes a sort of of that script you gave out.. but instend of saying test killed test 2 it says (Player Name) Has 12 Frags...
 
LUA:
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

Not the best way I think lol..
 
Old thread but maybe
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
Also put in creaturescript, dont forget to registerEvent in login.lua.
 
Old thread but maybe
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
Also put in creaturescript, dont forget to registerEvent in login.lua.


Code:
[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'
 
LOOOOOL OLD THREAD I DONT SEE THE DATE XDD

LUA:
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
 
getPlayerFrags(cid) has been deprecated .... use a custom one
LUA:
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
 
go to your creaturescripts folder, make a file in your scripts folder, then go to ur ccreaturescripts.xml and put something in there for that, then register the event in ur login.lua
 
work script:

Code:
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
 
Dunno why you bumped this, but anyway!
LUA:
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
 
Solution
Back
Top