Hi all,
So i'm trying to add a siren lights to my police car, but i got a problem using render.DrawSprite. Indead, i need a math formula that can calculate if i need to place lights in -10 and 10 on Y axis or on X axis relative to vehicle pos.
Here is my code :
VC means vars of my VehicleControler system.
[code]
if ent:GetNWBool("VC_DrawSirenLights") then
if(IsValid(ent)) then
if (ent.SirenSystem == 0) then
render.SetMaterial(Material("sprites/light_ignorez"))
render.DrawSprite(ent:GetPos() + Vector(0, 10, 75), 16, 16, Color(0, 0, 255, 255))
else
render.SetMaterial(Material("sprites/light_ignorez"))
render.DrawSprite(ent:GetPos() + Vector(0, -10, 75), 16, 16, Color(255, 0, 0, 255))
end
end
if (!timer.Exists("VC_SirenLights")) then
ent.SirenSystem = 1
timer.Create("VC_SirenLights", 1, 0, function()
if (ent.SirenSystem == 0) then
ent.SirenSystem = 1
else
ent.SirenSystem = 0
end
end)
end
elseif !ent:GetNWBool("VC_DrawSirenLights") and timer.Exists("VC_SirenLights") then
timer.Destroy("VC_SirenLights")
end
[/code]
Thanks by advance,
Yuri6037.
Can you post the error you got from the console?
I got no errors...
All is working it's just that i can't find the good position for the rendering. For example if you move on Gmod Y axis it will render correctly. But now move on X axis, and it will not render correctly.
You need to use vehicle:LocalToWorld( Vector( x, y, z ) ) to turn a localized position into a world-position attached to a vehicle.
Second, don't keep calling Material( ) in your function; set a local ( to the file ) variable outside of any rendering hooks and reference them when setting the material.
Thanks so much now it's working ! The siren is working.
Only one question ; i don't know if anyone can answer, but is there any model that adds Gyros to TDM BMW M5 E60 Car model ?
Sorry, you need to Log In to post a reply to this thread.