Overwriting TTT gamemode hooks.

I’m trying to overwrite a TTT karma hook, but when I try to overwrite Karma.CheckAutoKick it does not change at all. From my understanding all you do is inside of a function do your code then return it true and hook the function. Is that not correct?

To override it you just need to declare the function instead of hooking it.

such as:



function GM:PlayerSpawn(ply)

end


Assuming you do something like this in the init.lua, it will overwrite the derived gamemode function your targeting.

[editline]30th April 2016[/editline]

Also,

“TTTKarmaLow (ply)
Server
Called when a player is about to be kicked/banned because their karma has gone below the the autokick/ban level specified in the server’s configuration. Return false to prevent the player from being kicked/banned. Karma is checked at the end of a round, so if their karma continues to be low, this hook will be called after every round.”

If your just trying to disable the kick and do some other logic, use the hook instead of the advice above.



hook.Add("TTTKarmaLow","whatever",function(ply)

--some logic here to do what you want. I couldnt find information on how to access the players karma value, this function only passes the player entity....soo..goodluck!

return false
end)


I’m overwriting it inside of a addon lua file because when I edit the gamemode files on the server. When NFOServers add new GMOD updates it overwrites the gamemode files and I lose my work.

You’ll want to hook it and return false. That will make it not do anything, unless you add some of your own logic into it.

Make sure the lua your trying to run for this is in the proper place in your addon to run on the server only.

Dude there’s already a ConVar for it. Just place this in any .cfg - ttt_karma_low_autokick 0

Wanna do it with a code?
[lua]hook.Add( “TTTKarmaLow”, “PlayersWithLowKarmaWillNotGetKicked”, function() return false end )[/lua]
Go nuts

[editline]Just some stuff[/editline]
Of course that will be the clean solution.
Another solution will be doing this: [lua]KARMA.CheckAutoKick = function() end[/lua]

I never said I wanted to change the hook to where it did not kick the players. I edited the karma.lua and the init.lua inside of the TTT gamemode so that the kick/notification for both name changing and karma would be ULX notifications and bans. It worked perfectly but every update I have to replace the code which is a bother. I was trying to figure out how I could hook it and just change that one feature.

Well in that case you can either copy CheckAutoKick and edit the parts you want, or overrwite the Kick and KickBan functions