• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction [command] Kill for Gamemasters (With special function)

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Command kill for Gamemasters and GODs

...data/talkactions/scripts/kill.lua
Lua:
function onSay(cid, words, param)
	if(param == "") then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return TRUE
	end

	local t = string.explode(param, ",")
	local pid = getPlayerByNameWildcard(t[1])

	if(not tostring(t[3])) then
		doKillCreature(pid, t[2])
	end

	if(not tostring(t[4])) then
		doKillCreature(pid, t[2], t[3])
	end

	if(not tonumber(t[2])) then
		doKillCreature(pid, 0, t[2], t[3])
	end

	doKillCreature(pid, t[2], t[3], t[4])
	return TRUE
end

...data/talkactions/talkactions.xml
Lua:
	<talkaction log="yes" access="5" words="/kill" event="script" value="kill.lua"/>

...data/lib/functions.lua
Lua:
function doKillCreature(cid, time, lastHitKiller, mostDamageKiller)

local config = {
	deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
	sqlType = getConfigInfo('sqlType'),
	maxDeathRecords = getConfigInfo('maxDeathRecords')
}

	config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL

	if(config.deathListEnabled ~= TRUE) then
		return
	end

	if(not time) or (time == 0) or (not isNumber(time)) then
		doCreatureAddHealth(cid, - getCreatureHealth(cid))
	end

	addEvent(doCreatureAddHealth, time * 1000, cid, - getCreatureHealth(cid))

	local hitKillerName = lastHitKiller
	if(not lastHitKiller) then
		hitKillerName = "field item"
	end

	local lastKillerName = mostDamageKiller
	if(not mostDamageKiller) then
		lastKillerName = ""
	end

	db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(lastKillerName) .. ");")
	local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
	if(rows:getID() ~= -1) then
		local amount = rows:getRows(true) - config.maxDeathRecords
		if(amount > 0) then
			if(config.sqlType == DATABASE_ENGINE_SQLITE) then
				for i = 1, amount do
					db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
				end
			else
				db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
			end
		end
	end

	return LUA_ERROR
end

How to use?
You can use in this modes:
Lua:
/kill playerName --Kill the player instantaneously. (Killer showed in the deathslist will be a field item.)
/kill playerName, 2 --Kill the player in two seconds.
/kill playerName, 2, Demon --Kill the player in two seconds and killer showed in the deathslist will be a Demon.
/kill playerName, 2, Demon, Fire Elemental --Kill the player in two seconds and killer showed in the deathlist will be a Demon and lastHitKiller will be a fire elemental.
/kill playerName, Demon --Kill the player instantaneously and the killer showed in the deathlist will be a demon.
/kill playerName, Demon, Fire elemental --Kill the player instantaneously and killer showed in the deathlist will be a demon and lastHitKiller will b a fire elemental.
 
don't works for TFS 0.3.1 ^^ -.- can you fix so it works? (no errors, it just dont works)
 
Back
Top