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

Gold On Kill

Status
Not open for further replies.

Collz

Pandas Go RAWR!!!
Joined
Oct 10, 2008
Messages
2,091
Reaction score
58
Location
New York
Well, I'm in need of a script so when you pk someone, it will broadcast Player 1 has been killed by Player 2. Also I want it so you get 2 gp per player kill.

Thanks in advance!
 
Code:
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
 
Last edited:
I got this error when I killed someone

Code:
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>
 
I'm using TFS 8.5 0.3.5pl1

New Error:
Code:
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>
 
Last edited:
Try this one:
LUA:
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

or if you uses JDB scripts add this on lib/050-function:

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
 
Status
Not open for further replies.
Back
Top