Author Topic: Noclip for specific darkrp jobs  (Read 194 times)

0 Members and 1 Guest are viewing this topic.

Offline Nickolay

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Noclip for specific darkrp jobs
« on: March 04, 2019, 06:26:10 AM »
Hi,
I'm trying to create a code to let specific darkrp jobs use noclip.
Though, it doesn't work for ULX, anyone who could guide me on the right path?

Offline BlueNova

  • Full Member
  • ***
  • Posts: 108
  • Karma: 11
  • The most powerful force in the universe.
Re: Noclip for specific darkrp jobs
« Reply #1 on: March 04, 2019, 08:31:59 AM »
While I think this is a bad idea in general,

You could use a PlayerNoClip hook to achieve this
http://wiki.garrysmod.com/page/GM/PlayerNoClip

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 7987
  • Karma: 374
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Noclip for specific darkrp jobs
« Reply #2 on: March 04, 2019, 01:29:59 PM »
Oh, I don't know. I imagine, if really stretching RP as a whole, potential paranormal jobs... diety, ghost, poltergeist...

Nickolay,
I've never coded for DarkRP, but it shouldn't be too difficult in it's custom jobs/custom functions for jobs code area to set a variable for players, then use the hook BlueNova mentioned along with logic code like 'if not variable then return false else return'
You'd need to make it more complex than that to check for groups/admins, etc, but you should get the general idea.
The price one pays for pursuing any profession or calling is an intimate knowledge of its ugly side. - James Baldwin

Offline Nickolay

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Noclip for specific darkrp jobs
« Reply #3 on: March 06, 2019, 06:11:36 AM »
Thanks for the answers.
So I managed to make it so an usergroup can noclip only when they're in a specific darkrp job.
Though, this only covers the sandbox version of NoClip, aka they'll need to use it through the console instead of ULX.

Are there actually any ways to enable noclip, perhaps in a hook, as the ULX version of it?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 7987
  • Karma: 374
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Noclip for specific darkrp jobs
« Reply #4 on: March 06, 2019, 02:21:48 PM »
Well, not quite like you ask using a hook specific to noclip.
I think of two ways quickly. Both reasonably complex. My fellow coders could probably look and say "why not just do x" and x would be 20x easier than my thoughts.
1)
When player joins a job, grant them "ulx noclip ^" access. ULib/ULX don't just limit commands to groups - you can grant access to individual players.
The "^" would make sure they don't noclip anyone else, as ^ means only themself.
Challenges to this, you'd need to watch job changes and player disconnects/bans/etc to remove that access so they wouldn't keep it.
Additional complexity if you ever purposely wanted someone to have that individual access and were NOT part of that job. It could easily get removed when using code to ensure cleanup of the job noclip players.

2) (this would be what I do, but I like ULib challenges)
ULib, that ulx is built on, has a *sever side only* hook called
ULibCommandCalled
It can be used to monitor for any function used within ULib (including ulx functions)
I imagine using it to monitor for "ulx noclip", then check job, if job matches, use the direct function "ulx.noclip" rather than using "ULX access check included" command "ulx noclip"
My example pseudo code logic -

Code: [Select]
function noclip_job_check(calling_ply, cmd, args)
if cmd == "ulx noclip" and job == match then ulx.noclip(calling_ply, calling_ply) -- skip "ulx noclip" checks, go straight to noclip ulx function (ulx.noclip)
elseif cmd == "ulx noclip" then return -- if above logic didn't match, act normal, allow ULX to do it's normal access checks to determine if player/group player is in has normal noclip access.
end

hook.Add(ULibCommandCalled, "noclip check", noclip_job_check)

« Last Edit: March 06, 2019, 02:23:20 PM by JamminR »
The price one pays for pursuing any profession or calling is an intimate knowledge of its ugly side. - James Baldwin