General > Developers Corner

[Noob, help needed] ULX God Notify

<< < (3/3)

Fluttershy:

--- Quote from: Neku on September 24, 2014, 06:55:28 PM ---Instead of overwriting the gamemode function, try hooking onto it.

--- End quote ---
How would I go about doing that? I found this: [Click me]
Sorry, I did not read it when I asked. ^
So you want me to add to the hooks "hook.Add("PlayerNoClip", "DisableNoclip", DisableNoclip)" ?


--- Code: ---if (SERVER) then
function GM:PlayerNoClip( ply, on )
if not ply:IsAdmin() then return false end

if on then
ply:GodEnable()
else
ply:GodDisable()
end

return true end
end
hook.Add("PlayerNoClip", "DisableNoclip", DisableNoclip)

if (CLIENT) then
function PaintGodBox()
if LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then return end
draw.WordBox( 8, 5, ScrH() / 2, "Godmode: ON", "DermaDefault", Color(255,100,100,200), Color(255,255,255,255)) end
end
hook.Add( "HUDPaint", "GodModeBox", PaintGodBox )
--- End code ---
Tried this, Godmode is still non-functional. Will try removing GM: and see if that will work.

EDIT: Again, it did not work.
I am creating a shared.lua file for my gamemode "since it does not possess one" and adding this code onto it. Under the circumstances, this should work. I do not know why specifically the server function is refusing to work. This makes no sense. the ULX Godmode uses this exact same ply:GodEnable(). I do not understand why I cannot do the same.

Decicus:
"hook.Add()" takes three parameters.
One is the hook name, the second is the unique identifier, and the third parameter is the function name the hook should call (although it doesn't have to be a function name and just a function itself, but let's not think about that now).

Now the function name comes after "function". In this case it's "GM:PlayerNoClip". However, in your third "hook.Add()" parameter, it says "DisableNoclip", which means it's trying to call the "DisableNoclip" function which doesn't exist in your current code.

Other than that, you've done it correctly.

Fluttershy:

--- Quote from: Decicus on September 24, 2014, 10:18:25 PM ---"hook.Add()" takes three parameters.
One is the hook name, the second is the unique identifier, and the third parameter is the function name the hook should call (although it doesn't have to be a function name and just a function itself, but let's not think about that now).

Now the function name comes after "function". In this case it's "GM:PlayerNoClip". However, in your third "hook.Add()" parameter, it says "DisableNoclip", which means it's trying to call the "DisableNoclip" function which doesn't exist in your current code.

Other than that, you've done it correctly.

--- End quote ---
Wait, what are you saying, then? The third parameter must be GM:PlayerNoClip or should DisableNoclip be removed and left at that?

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given

[0] Board index

Go to full version