• Print

Author Topic: Check if a player is cloaked?  (Read 4777 times)

0 Members and 1 Guest are viewing this topic.

Offline clumen

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Check if a player is cloaked?
« on: January 05, 2018, 04:41:20 am »
Hello,

So I'm trying to make a HUD that shows whether the player is cloaked or not, I have tried some ways but they didn't work out, and not sure how or where to start? Any help would be appreciated, thank you!

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Check if a player is cloaked?
« Reply #1 on: January 05, 2018, 08:38:20 am »
Here is the code called when a player is set to invisible:

Code: Lua
  1. ply:DrawShadow( false )
  2. ply:SetMaterial( "models/effects/vol_light001" )
  3. ply:SetRenderMode( RENDERMODE_TRANSALPHA )
  4. ply:Fire( "alpha", visibility, 0 )
  5. ply:GetTable().invis = { vis=visibility, wep=ply:GetActiveWeapon() }
  6.  

You might be able to check the player's Material or render mode to see if they are what we set them to on invisible. I haven't tested this, so I don't know if it works clientside or not. Good start though, try it.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Check if a player is cloaked?
« Reply #2 on: January 05, 2018, 12:58:40 pm »
Code: [Select]
if ply:GetTable().invis ~= nil then -- they are invisible or some degree of it When uncloaking, we set .invis to nil.
Realize this only determines invisibility using ULib's version (ULX) of it.
If there is another gamemode or addon that makes players invisible, you'd have to dig into how the other code does it.

Additionally, our docs seem to indicate that will be server side only.
http://ulyssesmod.net/docs/files/lua/ulib/server/player-lua.html#invisible
You may have to find a method to share it with client HUD that is best for you.
« Last Edit: January 05, 2018, 01:06:56 pm by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Check if a player is cloaked?
« Reply #3 on: January 05, 2018, 03:11:59 pm »
Yeah, I didn't mention this because it was serverside only. You would need to include code to network this information to the client somehow. The solutions I gave (while a bit hacky) might work without adding any additional code for networking.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Check if a player is cloaked?
« Reply #4 on: January 05, 2018, 08:46:31 pm »
Great things we provide as members of Team Ulysses... are options. :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print