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

Action Frag Remover (Advanced)

dchampag

Well-Known Member
Joined
Jul 15, 2008
Messages
679
Reaction score
55
Location
USA
I seen a lot of posts about this looking for frag remover that doesn't remove all frags, here you can choose the amount to remove but never removing more than a months worth

I posted a partial script for week in someones post and they did not reply, so I tested myself and works, Enjoy

Lua:
local skulls = {
	SKULL_NONE,
	SKULL_YELLOW,
	SKULL_GREEN,
	SKULL_WHITE
}
local killIds = {}
local choice = ""
local timeremove = "none" -- Choices = day, week, month, none -- If none then the script will not remove frags only skull

function onUse(cid, item, frompos, item2, topos)
	local times = {today = (time - 86400), week = (time - (7 * 86400)), month = (time - (30*86400))}
	if timeremove == 'day' then
		choice = times.today
	elseif timeremove == 'week' then
		choice = times.week
	elseif timeremove == 'month' then
		choice = times.month
	end
	local playerskull = getCreatureSkullType(cid)

	if timeremove == "none" then
		if isInArray(skulls, playerskull) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This can only be used on red skull")
			return 0
		else
			doCreatureSetSkullType(cid, skulls[1])
			setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your skull has been removed!")
		end
	else
		local result = db.getResult("SELECT `pk`.`kill_id` 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` >= " .. choice)
		if(result:getID() ~= -1) then
			repeat
				table.insert(killIds, result:getDataInt("kill_id"))
			until not result:next()
			result:free()
		end
		if isInArray(skulls, playerskull) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This can only be used on red skull")
			return 0
		else
			doCreatureSetSkullType(cid, skulls[1])
			setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
			for i=1, #killIds do
				db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN ("..killIds[i]..")")
			end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your frags have been removed!")
		end
	end
	doRemoveItem(item.uid)
	return true
end


Now can make it not remove frags only skull

Please note that if a player uses this and it is set to not remove any frags then, the player will get their skull back as soon as they frag again
 
Last edited:
At the moment, red and black, but if you would like it to be able to then remove SKULL_WHITE from
Lua:
local skulls = {
	SKULL_NONE,
	SKULL_YELLOW,
	SKULL_GREEN,
	SKULL_WHITE
}
and change this
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This can only be used on red skull")
to
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This can only be used when you are skulled")
or something else that you would like it to say on cancel
 
At the moment, red and black, but if you would like it to be able to then remove SKULL_WHITE from
Lua:
local skulls = {
	SKULL_NONE,
	SKULL_YELLOW,
	SKULL_GREEN,
	SKULL_WHITE
}
and change this
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This can only be used on red skull")
to
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This can only be used when you are skulled")
or something else that you would like it to say on cancel



Thanks m8
 
error on tfs 0.2.15 help please ;)

[01/06/2013 18:56:50] Lua Script Error: [Action Interface]
[01/06/2013 18:56:50] data/actions/scripts/other/skull.lua:eek:nUse
[01/06/2013 18:56:50] data/actions/scripts/other/skull.lua:12: attempt to perform arithmetic on global 'time' (a nil value)
[01/06/2013 18:56:50] stack traceback:
[01/06/2013 18:56:50] [C]: in function '__sub'
[01/06/2013 18:56:50] data/actions/scripts/other/skull.lua:12: in function <data/actions/scripts/other/skull.lua:11>
 
Back
Top