General > Developers Corner

Noclip for specific darkrp jobs

(1/2) > >>

Nickolay:
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?

BlueNova:
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

JamminR:
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.

Nickolay:
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?

JamminR:
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: ---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)


--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version