ULX

Author Topic: Noclip for specific darkrp jobs  (Read 5878 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: 113
  • Karma: 13
  • 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: 8096
  • Karma: 390
  • 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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

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: 8096
  • Karma: 390
  • 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 »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Taylorr<3/only.fans

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Noclip for specific darkrp jobs
« Reply #5 on: July 04, 2020, 09:13:52 AM »
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)


Where would I put this code for it to work and where do I specify which job I want it to affect? I have a job called Moderator on Duty and I want to set it to where you can only noclip if you are playing as that job so staff don't abuse noclip powers during roleplay. I found a way to do this before but it used the sandbox noclip. I'm looking for a way to allow ulx noclip on only the player playing as the job so they cant toggle noclip on others. Thx also, ignore my name, it was a joke...