Hi, try this
local lastDeathTime = {}
function onPlayerWasted(totalAmmo, killer)
local playerName = getPlayerName(source)
local currentTime = getTickCount()
-- Check if the player has already been processed recently
if lastDeathTime[playerName] and currentTime - lastDeathTime[playerName] < 1000 then
return
end
lastDeathTime[playerName] = currentTime
if isElement(killer) and getElementType(killer) == "player" then
local killerName = getPlayerName(killer)
local victimName = getPlayerName(source)
if killer == source then -- suicide
outputChatBox(playerName .. " died")
else
outputChatBox(killerName .. " killed " .. victimName)
end
else
outputChatBox(playerName .. " died")
end
end
addEventHandler("onPlayerWasted", root, onPlayerWasted)