Custom Weapon Switch HUD and ULX Voting

Hi everyone. I got some problems with solving this problem. recently i used PlayerBindPress hook to hook weapon switching to show custom HUD. I returned “true” in the end of this hook to prevent opening default weapon switching hud. But if i use “true” it also makes impossible to choose options somewhere (ulx vote menu for example). Later i decided to change from “return true” to “return” and hide CHudWeaponSelection. But now ‘lastinv’ doesn’t work. Is there any way to fix that?

P.S. I looked into TTT code and there were “true” returns, but ULX voting works well. Maybe i missed sth?

Thanks!

Oh ok I get it now.
Wow you worded that… weirdly.
What do you mean where in the TTT ocde it returns true?
Also what is lastinv?

He ment in the TTT Gamemode the creator made the PlayerBindPress return true, to prevent the wep menu from popping up.

Ohh ok.
Well can you show us both of the codes then?

Yep, i will include the part of code, here is it:


hook.Add("PlayerBindPress","PlayerBindPress", function(p, bind, pressed)

	if not pressed then return end

	if string.find(bind, "slot1") then
		surface.PlaySound("common/wpn_moveselect.wav");
		sTab = 1;
		return true
	end
end


function GM:PlayerBindPress(ply, bind, pressed)
   if not IsValid(ply) then return end

   if bind == "invnext" and pressed then
      ...
   elseif string.sub(bind, 1, 4) == "slot" and pressed then
      local idx = tonumber(string.sub(bind, 5, -1)) or 1

      -- if radiomenu is open, override weapon select
      if RADIO.Show then
         RADIO:SendCommand(idx)
      else
         WSWITCH:SelectSlot(idx)
      end
      return true
      ...
end

I also tried to use function istead of hook - didnt help

heres the thing:



function GM:PlayerBindPress(ply, bind, pressed)
   if not IsValid(ply) then return end

   if bind == "invnext" and pressed then
      ...
   elseif string.sub(bind, 1, 4) == "slot" and pressed then
      local idx = tonumber(string.sub(bind, 5, -1)) or 1

      -- if radiomenu is open, override weapon select
      if RADIO.Show then
         RADIO:SendCommand(idx)
      else
         WSWITCH:SelectSlot(idx)
      end
      return true
      ...
end


TTT uses custom functions to display the radio select if… etc

WSWITCH is custom library. The same as RADIO. It’s equal to functions. So, it’s not the problem solution.

[editline]24th August 2015[/editline]

Here is a WSWITCH code: https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/terrortown/gamemode/cl_wepswitch.lua