zombiesurvival-evolved/gamemodes/zombiesurvival/gamemode/cl_floatingscore.lua

45 lines
1.5 KiB
Lua
Raw Normal View History

2014-10-02 08:49:54 +08:00
net.Receive("zs_healother", function(length)
gamemode.Call("HealedOtherPlayer", net.ReadEntity(), net.ReadUInt(16))
end)
net.Receive("zs_repairobject", function(length)
gamemode.Call("RepairedObject", net.ReadEntity(), net.ReadUInt(16))
end)
net.Receive("zs_commission", function(length)
gamemode.Call("ReceivedCommission", net.ReadEntity(), net.ReadEntity(), net.ReadUInt(16))
end)
function GM:ReceivedCommission(crate, buyer, points)
gamemode.Call("FloatingScore", crate, "floatingscore_com", points)
end
function GM:HealedOtherPlayer(other, points)
gamemode.Call("FloatingScore", other, "floatingscore", points)
end
function GM:RepairedObject(other, points)
gamemode.Call("FloatingScore", other, "floatingscore", points)
end
local cvarNoFloatingScore = CreateClientConVar("zs_nofloatingscore", 0, true, false)
function GM:FloatingScore(victim, effectname, frags, flags)
local isvec = type(victim) == "Vector"
if cvarNoFloatingScore:GetBool() or not isvec and (not victim:IsValid() or victim:IsPlayer() and victim:Team() == MySelf:Team()) then return end
effectname = effectname or "floatingscore"
local pos = isvec and victim or victim:NearestPoint(EyePos())
local effectdata = EffectData()
effectdata:SetOrigin(pos)
effectdata:SetScale(flags or 0)
if effectname == "floatingscore_und" then
effectdata:SetMagnitude(frags or GAMEMODE.ZombieClasses[victim:GetZombieClass()].Points or 1)
else
effectdata:SetMagnitude(frags or 1)
end
util.Effect(effectname, effectdata, true, true)
end