• Print

Author Topic: Have a Gamemode Detect a ULX function?  (Read 6399 times)

0 Members and 1 Guest are viewing this topic.

Offline Zombine

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Have a Gamemode Detect a ULX function?
« on: August 15, 2014, 03:52:02 pm »
Like the title says. Say I'm in DarkRP, and I'd like the gamemode to run a certain feature if the user is cloaked.
Specifically, if the user is cloaked, it will hide the name and job tag above their head.
Is this at all possible?

I have some code someone gave me to hide the tags if the player is using a certain job, but I'm unsure if it can be made to interact with ULX.

Code: [Select]
hook.Add("HUDShouldDraw","DarkRP_HideJobsEntityDisplay",function(hudName)
   if hudName ~="DarkRP_EntityDisplay"thenreturnend

   local playersToDraw ={}
   for _,ply inpairs(player.GetAll())do
       if ply:Team()~= TEAM_SOMEJOB then
           table.insert(playersToDraw, ply)
       end
   end
   returntrue, playersToDraw
end)

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: Have a Gamemode Detect a ULX function?
« Reply #1 on: August 15, 2014, 04:11:21 pm »
You would have to modify the existing cloak command or write one yourself.
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline Zombine

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Have a Gamemode Detect a ULX function?
« Reply #2 on: August 15, 2014, 04:12:38 pm »
All right, I suppose I'll try that.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Have a Gamemode Detect a ULX function?
« Reply #3 on: August 15, 2014, 07:52:56 pm »
You would have to modify the existing cloak command or write one yourself.
Nah, you don't.
You could use ULibCommandCalled or perhaps ULibPostTranslatedCommand to look for "ulx cloak" and run any function/code needed.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Zombine

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Have a Gamemode Detect a ULX function?
« Reply #4 on: August 16, 2014, 11:54:40 am »
So then do you suppose I might be able to sneak this in there to have it run the rest of the code?

Code: [Select]
if ply:ULibCommandCalled( ply, ULib.invisible ) ~= true
I'm about 99.99% sure that won't work, because I am terrible with lua, but thank you anyway JamminR. I'll go experiment.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Have a Gamemode Detect a ULX function?
« Reply #5 on: August 16, 2014, 01:15:58 pm »
if ply:GetMaterial() == "models/effects/vol_light001" then ...

Offline Zombine

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Have a Gamemode Detect a ULX function?
« Reply #6 on: August 16, 2014, 04:03:49 pm »
if ply:GetMaterial() == "models/effects/vol_light001" then ...

Thanks. So this is what it looks like now.
Code: Lua
  1. hook.Add("HUDShouldDraw", "DarkRP_HideJobsEntityDisplay", function(hudName)
  2.     if hudName ~= "DarkRP_EntityDisplay" then return end
  3.  
  4.     local playersToDraw = {}
  5.     for _,ply in pairs(player.GetAll()) do
  6.         ply:GetMaterial() == "models/effects/vol_light001" then
  7.             table.insert(playersToDraw, ply)
  8.         end
  9.     end
  10.     return true, playersToDraw
  11. end)

I'm assuming that this wouldn't resume drawing their nametag if their material is no longer vol_light, so I added an else statement. Does it look correct?

Code: Lua
  1. hook.Add("HUDShouldDraw", "DarkRP_HideJobsEntityDisplay", function(hudName)
  2.     if hudName ~= "DarkRP_EntityDisplay" then return end
  3.  
  4.     local playersToDraw = {}
  5.     for _,ply in pairs(player.GetAll()) do
  6.         ply:GetMaterial() == "models/effects/vol_light001" then
  7.             table.insert(playersToDraw, ply)
  8.         end
  9.     else
  10.             table.remove(playersToDraw, ply)
  11.         end
  12.     end
  13.     return true, playersToDraw
  14. end)

  • Print