I write Visor swep for assassin and other, required buy and ect....
And go:
Visor glows some team at some colour - assassin red color, citizen green colour, visor work only if player select this visor in weapon selector, and if player change weapon - wallhack off, and this visor places overlay to player screen, and if player change weapon - overlay off. In this code for this all okay?
cl_init.lua
if GM:WeaponEquip( weapon_visor, Player ) then
hook.Add( "PreDrawHalos", "AddHalos", function()
local Security = {TEAM_POLICE, TEAM_POLICE2, TEAM_POLICE3, TEAM_POLICE4, TEAM_POLICE5, TEAM_POLICEMEDIK, TEAM_POLICEMEDIK2, TEAM_POLICEMEDIK3, TEAM_POLICEMEDIK4, TEAM_POLICEMEDIK5 TEAM_POLICE_HEAVY, TEAM_POLICE_HEAVY2, TEAM_PALATIN, TEAM_OMON, TEAM_OMON2, TEAM_OMOSN, TEAM_OMOSN2, TEAM_CHIEF, TEAM_MAYOR, TEAM_PSYONIC}
local Civil = {TEAM_CITIZEN, TEAM_HOBO, TEAM_STORE, TEAM_GUN, TEAM_MEDIK}
local Maniac = {TEAM_MANYAK}
local Engineer = {TEAM_ENGINEER_CLASS_01, TEAM_ENGINEER_CLASS_02, TEAM_ENGINEER_CLASS_03, TEAM_ENGINEER_CLASS_04, TEAM_ENGINEER_CLASS_05}
local Bandits = {TEAM_GANG, TEAM_MOB, TEAM_DRUGER, TEAM_DRUGER2, TEAM_GUNCR}
local Assassin = {TEAM_HIT}
local Clones = {TEAM_SW_SCOUT, TEAM_SW_TROOPER, TEAM_SW_MEDIK, TEAM_SW_HEAVY, TEAM_SW_HEAVY2, TEAM_SW_PALATIN, TEAM_SW_REGENT, TEAM_SW_SNIPER}
halo.Add(Security, Color(0, 183, 255), 1, 1, 1, true, false)
halo.Add(Civil, Color(0, 255, 34), 1, 1, 1, true, false)
halo.Add(Maniac, Color(120, 0, 48), 1, 1, 1, true, false)
halo.Add(Engineer, Color(255, 153, 0), 1, 1, 1, true, false)
halo.Add(Bandits, Color(0, 255, 102), 1, 1, 1, true, false)
halo.Add(Assassin, Color(255, 0, 0), 1, 1, 1, true, false)
halo.Add(Clones, Color(255, 255, 255), 1, 1, 1, true, false)
local function swrp_draw_mask()
local mask = "effects/assassin_visor"
DrawMaterialOverlay(mask, 0)
end
hook.Add("RenderScreenspaceEffects", "swrp_draw_mask", swrp_draw_mask)
else return
end
end
end
Firstly, I'd suggest you get a GLua linter to make sure your code doesn't have any fundamental errors - this can save you a lot of time. There are several issues with this.
You have missed a comma in the Security table:
TEAM_POLICEMEDIK5 TEAM_POLICE_HEAVY,
You shouldn't wrap the hook declaration with a condition; this won't work anyway since it's another gamemode hook. The code you want to check the current weapon is:
if LocalPlayer():GetActiveWeapon():GetClass() != "weapon_visor" then return end
and this should be placed in the hook callback function right at the top.
The whole RenderScreenspaceEffects block needs to be outside of your PreDrawHalos callback.
Your hooks should have unique names to avoid interfering with/being interefered by other hooks.
Finally, halo.Add works on a table of entities, not on a table of team numbers (which is what the TEAM_* variables represent). I suggest you take a look at the GMod and DarkRP wikis, this will tell you how to group players into tables of teams to draw the appropriate halos.
TL;DR
hook.Add( "PreDrawHalos", "AddVisorWeaponHalos", function()
if LocalPlayer():GetActiveWeapon():GetClass() != "weapon_visor" then return end
-- Tables and halo.Add stuff here
end)
local function swrp_draw_mask()
local mask = "effects/assassin_visor"
DrawMaterialOverlay(mask, 0)
end
hook.Add("RenderScreenspaceEffects", "swrp_draw_mask", swrp_draw_mask)
thanks
Sorry, you need to Log In to post a reply to this thread.