Hey dear readers,
im currently working on an Icon that get drawed if a special hook called.
Here the Codes:
local generator_pos
local ICON_EXITHELP = Material("icons/icon_exit.png")
local function AddGenerator()
local pos, endtime
pos = net.ReadVector()
if !LocalPlayer():Alive() then return end
generator_pos = pos
end
net.Receive("sls_popularhelp_AddGenerator", AddGenerator)
-- GeneratorIcon
if LocalPlayer():Team() != TEAM_KILLER && generator_pos then
if !GM.ROUND.Active then
generator_pos = nil
else
local pos1 = generator_pos:ToScreen()
surface.SetDrawColor(Color(255, 255, 255))
surface.SetMaterial(ICON_EXITHELP)
surface.DrawTexturedRect(pos1.x - 64, pos1.y - 64, 128, 128)
end
end
This was the Client File… The Draw of Material Works
Now My Problem File:
util.AddNetworkString("sls_popularhelp_AddGenerator")
local function AddGenerator(pos)
if !GM.ROUND.Active || !IsValid(GM.ROUND.Killer) then return end
net.Start("sls_popularhelp_AddGenerator")
net.WriteVector(pos)
net.Send(GM.ROUND.Survivors)
end
local function GeneratorAppear()
--Icon Generator
AddGenerator(Vector(ents.FindByName( "sls_generator" )))
end
hook.Add("sls_round_StartWaitingPolice", "sls_round_GeneratorIcon", GeneratorAppear)
If this last hook it calls it shows the Icon defined in the client file but not on the position where the entity spawned on the map.
I just need the right Vector from the Entity… The code from the entity here:
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local ent = ents.Create("sls_generator")
ent:SetPos( tr.HitPos + tr.HitNormal )
ent:Spawn()
return ent
end
Thanks for reading this and have a nice evening.