mirror of
https://github.com/etlegacy/etlegacy-lua-scripts.git
synced 2025-02-16 17:01:52 +00:00
Counting sprees for players
This commit is contained in:
parent
a4ec562ab9
commit
2665ee88a4
1 changed files with 28 additions and 4 deletions
|
@ -12,21 +12,45 @@ local version = "0.1"
|
|||
local WORLDSPAWN_ENTITY = 1022
|
||||
local ENTITYNUM_NONE = 1023
|
||||
|
||||
local killingSprees = {}
|
||||
|
||||
function et_InitGame()
|
||||
et.RegisterModname(modname .. " ".. version)
|
||||
end
|
||||
|
||||
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)
|
||||
local targetTeam = et.gentity_get(target, "sess.sessionTeam")
|
||||
local attackerTeam = et.gentity_get(attacker, "sess.sessionTeam")
|
||||
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
|
||||
|
||||
local targetGuid = getGuid(target)
|
||||
killingSprees[targetGuid] = 0
|
||||
|
||||
if suicide or teamkill or killerIsNotPlayer then
|
||||
et.G_Print("suicide or teamkill or killerIsNotPlayer\n")
|
||||
return
|
||||
end
|
||||
|
||||
local attackerGuid = getGuid(attacker)
|
||||
killingSprees[attackerGuid] = killingSprees[attackerGuid] + 1
|
||||
|
||||
et.G_Print("target " .. targetGuid .. " killed by " .. attackerGuid .. "\n")
|
||||
et.G_Print("target spree " .. killingSprees[targetGuid] .. "\nattacker spree " .. killingSprees[attackerGuid] .. "\n")
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue