Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if CLIENT then
- local matMaterial = Material( "pp/texturize" )
- local m = CreateMaterial( 'pk+player2', "VertexLitGeneric", { ["$basetexture"] = "models/debug/debugwhite", ["$model"] = 1, ["$ignorez"] = 1 } );
- local function isPlayer(e) return IsValid(e) and e.GetClass and e:GetClass() == "player" end
- local PlayerProps = {}
- function tex()
- local pMaterial = Material('pp/texturize/plain.png')
- render.UpdateScreenEffectTexture()
- matMaterial:SetFloat( "$scalex", ( ScrW() / 64 ) * 1 )
- matMaterial:SetFloat( "$scaley", ( ScrH() / 64 / 8 ) * 1 )
- matMaterial:SetTexture( "$basetexture", pMaterial:GetTexture( "$basetexture" ) )
- render.SetMaterial( matMaterial )
- render.DrawScreenQuad()
- render.SuppressEngineLighting(false)
- end
- hook.Add( "PostDrawOpaqueRenderables", "zed", tex )
- local function TableSortByDistance(former, latter) return latter:GetPos():Distance( LocalPlayer():GetPos() ) > former:GetPos():Distance( LocalPlayer():GetPos() ) end
- function GetPlayersByDistance() local players = player.GetAll(); table.sort( players, TableSortByDistance ); return players; end
- function pkplayer()
- for _,v in next, ents.FindByClass('prop_physics') do
- if IsValid(v) then
- cam.Start3D( LocalPlayer():EyePos(), LocalPlayer():EyeAngles() );
- render.SuppressEngineLighting(false)
- render.SetColorModulation( 1, 0, 0, 1 );
- render.SetModelLighting( 4, 1, 0, 0 );
- render.MaterialOverride( m );
- v:DrawModel()
- cam.End3D();
- end
- end
- for _, ply in pairs( GetPlayersByDistance() ) do
- if (ply != LocalPlayer() && IsValid( ply ) && ply:Alive() && ply:Health() > 0 && ply:Team() != TEAM_SPECTATOR && !ply:IsDormant()) then
- cam.Start3D( LocalPlayer():EyePos(), LocalPlayer():EyeAngles() );
- render.SuppressEngineLighting(true)
- render.SetColorModulation( 0.7, 0, 0, 1 );
- render.SetModelLighting( 4, 1, 0, 0 );
- render.MaterialOverride( m );
- render.SetMaterial(m)
- ply:DrawModel();
- if (IsValid( ply:GetActiveWeapon() )) then
- local clr = ply:GetWeaponColor()
- render.SetColorModulation( math.abs(clr.x), math.abs(clr.y), math.abs(clr.z), 1 );
- ply:GetActiveWeapon():DrawModel();
- end
- render.SuppressEngineLighting(false);
- cam.End3D();
- end
- end
- end
- hook.Add( "RenderScreenspaceEffects", "zed", pkplayer )
- hook.Add("PreDrawPlayerHands", "zed", function(vm, ply, wep)
- render.SuppressEngineLighting(true)
- render.SetColorModulation( 0.7, 0, 0, 1 );
- render.MaterialOverride( m )
- end)
- hook.Add("PreDrawViewModel", "zed", function(vm, ply, wep)
- if IsValid(ply) then
- local clr = ply:GetWeaponColor()
- render.SuppressEngineLighting(true)
- render.SetColorModulation(
- math.abs(clr.x) < 0.5 and clr.x or 0.5,
- math.abs(clr.y) < 0.5 and clr.y or 0.5,
- math.abs(clr.z) < 0.5 and clr.z or 0.5
- ,1);
- render.MaterialOverride( m )
- end
- end)
- elseif SERVER then
- local function FindOwner( ent )
- local owner, _ = ent:CPPIGetOwner()
- return owner or ent.FPPOwner or nil -- Fallback to FPP variable if CPPI fails.
- end
- local function isPlayer(e) return IsValid(e) and e.GetClass and e:GetClass() == "player" end
- local function DamageFilter( target, d ) -- d for damage info.
- local attacker, inflictor, damage, type = d:GetAttacker(), d:GetInflictor(), d:GetDamage(), d:GetDamageType()
- local dents = {attacker, inflictor}
- for _,v in next, dents do
- local str = '_pk='..tostring(CurTime())..v:EntIndex()
- if isPlayer(target) and damage > 0 then
- if not isPlayer(v) then
- local o = FindOwner(v)
- timer.Create(str, 0.0001, 1, function()
- if IsValid(target) and IsValid(o) and (target.Alive and not target:Alive()) then
- if target ~= o then
- o:AddFrags(1)
- else
- o:AddFrags(-2)
- end
- end
- end)
- end
- end
- end
- end
- hook.Add( "EntityTakeDamage", "zed", DamageFilter )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement