Dear LUD's!
I got 2 problems I can't seem to figure out with the quad lua:
1. How do I know when a player goes spectator?
function player_spawn( player_entity ) doesnt work for that as you don't "spawn" as spectator. Is there a forward to see when someone changes to spectator? I need it to remove the custom quad hud icon for specs.
2. The hud icon use a vtf and a vmt file but I can't get them to upload to the clients. The res file looks like this:
Code:
"resources"
{
"maps/conc_adam.bsp" "file"
"maps/conc_adam.txt" "file"
"maps/conc_adam.lua" "file"
"materials/vgui/hud_quad.vtf" "file"
"materials/vgui/hud_quad.vmt" "file"
}
I can't find any lua that uploads custom icons, so there is no examples.
I know, maybe I should pick another folder than materials/vgui as thats the main mod folder. I will change that. How do you precache custom content like this?
base_quad.lua
Code:
-- base_quad.lua
----------------------------------------------------------------------
-- Quad icon
----------------------------------------------------------------------
hudicon = "hud_quad"
hudx = 5
hudy = 110
hudw = 48
hudh = 48
huda = 1
hudstatusicon = "hud_quad.vtf"
----------------------------------------------------------------------
-- Set hud icon at spawn
----------------------------------------------------------------------
function player_spawn( player_entity )
local player = CastToPlayer( player_entity )
local class = player:GetClass()
if class == Player.kSoldier or class == Player.kDemoman then
if player:GetTeamId() ~= Team.kRed then
RemoveHudItem( player, hudstatusicon )
else
AddHudIcon(player, hudicon, hudstatusicon, hudx, hudy, hudw, hudh, huda)
end
else
RemoveHudItem( player, hudstatusicon )
end
end
----------------------------------------------------------------------
-- Set quad and invul when damage is taken by soldier and demoman
-- on red team
----------------------------------------------------------------------
function player_ondamage( player, damageinfo )
if player:GetTeamId() ~= Team.kRed then return end
local class = player:GetClass()
if class == Player.kSoldier or class == Player.kDemoman then
local damageforce = damageinfo:GetDamageForce()
damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
damageinfo:SetDamage( 0 )
end
end