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

[Lua Script] Kills (solved)

StormRusher

New Member
Joined
Dec 23, 2009
Messages
138
Reaction score
0
Well i need a script to add +1 to PlayerStorageValue(3) every time a player kill someone (onKill)

And another to show the Storage gained in the day, and the all storage gained...

Hope its possible, thanks :)
 
Last edited:
could be something like this:

"killcount.lua" add this script into your creaturescripts/scripts
Lua:
function onKill(cid, target, lastHit)
local killcount = getPlayerStorageValue(cid, 10000)
local corpse = getPlayerName(target)
  if isPlayer(target) == true then
   setPlayerStorageValue(cid, 10000, killcount +1)
   doPlayerSendTextMessage(cid, 22, 'You killed '..corpse..'!\nYour current Killcount is: '..killcount..'')
  end
return true
end

!!NOT TESTED!!

also add those lines (depending on your server version)

creaturescripts/creaturescripts.xml
Lua:
<event type="kill" name="Killcount" script="killcount.lua"/>

OR

<event type="kill" name="Killcount" event="script" value="killcount.lua"/>

also add this line into your creaturescripts/scripts/login.lua

Lua:
registerCreatureEvent(cid, "Killcount")

Should work although.

Regarding the other scripts I think this has to be done
with a talkaction command to request the killcounts of 1 day,
or maybe something else, I'll try it with some talkactions.

Maybe someone else got another solution.
 
Last edited:
#first script:
Code:
local storage = 10000
function onKill(cid, target, lastHit)
	if isPlayer(target) == TRUE then
		setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
		doPlayerSendTextMessage(cid, 22, "You killed " .. getCreatureName(target) .. "! Your current killcount is: " .. getPlayerStorageValue(cid, storage))
	end
	return TRUE
end
#second requires creating a new table, or a column in player_storage
 
For the second script, this should work:

add this script into your talkactions/scripts
name it "kills.lua"
Lua:
function onSay(cid, words, param, channel)
 kills = getPlayerStorageValue(cid, 10000)
 doPlayerSendTextMessage(cid, 22, 'Your current Killcount is: '..kills..'')
return TRUE
end

add this line into your talkactions.xml
Lua:
<talkaction words="!kills" event="script" value="kills.lua"/>

But the request of kills of 1 day is something tricky.
Can't help you there, sorry.
 
#first script:
Code:
local storage = 10000
function onKill(cid, target, lastHit)
	if isPlayer(target) == TRUE then
		setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
		doPlayerSendTextMessage(cid, 22, "You killed " .. getCreatureName(target) .. "! Your current killcount is: " .. getPlayerStorageValue(cid, storage))
	end
	return TRUE
end
#second requires creating a new table, or a column in player_storage

Hmm ok, and how can i do that?

@zyntax

ty for help
 
i have found this script, i think it can be edited to do what i want...

Lua:
local config = {
	advancedFragList = getBooleanFromString(getConfigValue("advancedFragList"))
}

function onSay(cid, words, param, channel)
	local time = os.time()
	local times = {today = (time - 86400), week = (time - (7 * 86400))}

	local contents = {day = {}, week = {}, month = {}}
	local result = 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 = {
				name = result:getDataString("name"),
				level = result:getDataInt("level"),
				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)
	}
	if(config.advancedFragList) then
		local result = "Frags gained today: " .. size.day .. "."
		if(size.day > 0) then
			for _, content in ipairs(contents.day) do
				result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
			end

			result = result .. "\n"
		end

		result = result .. "\nFrags gained this week: " .. (size.day + size.week) .. "."
		if(size.week > 0) then
			for _, content in ipairs(contents.week) do
				result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
			end

			result = result .. "\n"
		end

		result = result .. "\nFrags gained this month: " .. (size.day + size.week + size.month) .. "."
		if(size.month > 0) then
			for _, content in ipairs(contents.month) do
				result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
			end

			result = result .. "\n"
		end

		local skullEnd = getPlayerSkullEnd(cid)
		if(skullEnd > 0) then
			result = result .. "\nYour " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd)
		end

		doPlayerPopupFYI(cid, result)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You currently have " .. size.day .. " frags today, " .. (size.day + size.week) .. " this week and " .. (size.day + size.week + size.month) .. " this month.")
		if(size.day > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last frag at " .. os.date("%d %B %Y %X", contents.day[1].date) .. " on level " .. contents.day[1].level .. " (" .. contents.day[1].name .. ").")
		end

		local skullEnd = getPlayerSkullEnd(cid)
		if(skullEnd > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd))
		end
	end

	return true
end
 
If you use the latest TFS (or 0.3.4++ I guess) then you're able to use it.

Just go to your config.lua and search the line "AdcancedFragList".
If you have it set it to "AdcancedFragList" = true

Then there should be a proper talkaction (like !fraglist) to activate it.
 
Back
Top