etlegacy-lua-scripts/killing-spree/killing-spree.lua

57 lines
1.5 KiB
Lua
Raw Normal View History

2018-02-10 20:06:59 +00:00
--[[
Author: Kewin Polok [Sheldar]
Contributors:
License: MIT
2018-02-10 20:06:59 +00:00
Description: Script for killing spree sounds
2018-02-10 20:06:59 +00:00
]]--
local modname = "killing-spree"
local version = "0.1"
local WORLDSPAWN_ENTITY = 1022
local ENTITYNUM_NONE = 1023
2018-02-11 13:48:20 +00:00
local killingSprees = {}
function et_InitGame()
et.RegisterModname(modname .. " ".. version)
end
2018-02-11 13:48:20 +00:00
function getTeam(clientNumber)
return et.gentity_get(clientNumber, "sess.sessionTeam")
end
function getGuid(clientNumber)
return et.Info_ValueForKey( et.trap_GetUserinfo(clientNumber), "cl_guid")
end
function et_ClientBegin(clientNumber)
local guid = getGuid(clientNumber)
killingSprees[guid] = 0
end
function et_Obituary(target, attacker, meansOfDeath)
2018-02-11 13:48:20 +00:00
local targetTeam = getTeam(target)
local attackerTeam = getTeam(attacker)
local suicide = target == attacker
local teamkill = targetTeam == attackerTeam
local killerIsNotPlayer = killer == WORLDSPAWN_ENTITY or killer == ENTITYNUM_NONE
2018-02-11 13:48:20 +00:00
local targetGuid = getGuid(target)
killingSprees[targetGuid] = 0
if suicide or teamkill or killerIsNotPlayer then
2018-02-11 13:48:20 +00:00
et.G_Print("suicide or teamkill or killerIsNotPlayer\n")
return
end
2018-02-11 13:48:20 +00:00
local attackerGuid = getGuid(attacker)
killingSprees[attackerGuid] = killingSprees[attackerGuid] + 1
2018-02-11 13:48:20 +00:00
et.G_Print("target " .. targetGuid .. " killed by " .. attackerGuid .. "\n")
et.G_Print("target spree " .. killingSprees[targetGuid] .. "\nattacker spree " .. killingSprees[attackerGuid] .. "\n")
end