Hello, working on a cp test addon that disables gov jobs until a test is passed. I've got pretty much everything done besides the actual team disable which I can't figure out.. I looked through some team hooks on the wiki and played around with them couldn't really get what I wanted. I'm wondering what the proper way is to add a check before a player joins a team.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerCanJoinTeam]GM:PlayerCanJoinTeam[/url]
Return false if they can't. (DO NOT return true if they can)
[editline]4th April 2017[/editline]
ninja'd
[QUOTE=code_gs;52056572][url]http://wiki.garrysmod.com/page/GM/PlayerCanJoinTeam[/url][/QUOTE]
So would I have that in a hook.Add()? The only way I have used hooks is in a hook.Add... I was thinking of putting this function in a steamauth so that I can set the team join to false, and then when the player completes and passes the test I would set it to true.. But I don't understand how I would do that using hook.Add()?
The function can be used in hook.Add. Almost all GM functions can.
[QUOTE=code_gs;52056605]The function can be used in hook.Add. Almost all GM functions can.[/QUOTE]
Right, but wouldn't this be a time where I wouldn't want to use a hook.Add()? I would be using it in a steam auth hook already.
[QUOTE=MrRalgoman;52056625]Right, but wouldn't this be a time where I wouldn't want to use a hook.Add()? I would be using it in a steam auth hook already.[/QUOTE]
You would want to use hook.Add; what is your Steam Auth hook for?
[lua]hook.Add("PlayerCanJoinTeam", "Some descriptive identifier", function(ply, team)
if team == THE_RELEVANT_TEAM_ID
and not DO_YOUR_TEST(ply)
then
return false
end
end[/lua]
[QUOTE=code_gs;52056628]You would want to use hook.Add; what is your Steam Auth hook for?[/QUOTE]
[CODE]local function sendData(ply, steamID, uniqueID)
for k, v in pairs(questions) do
net.Start("sendQuestions")
net.WriteString(v)
net.Send(ply)
end
end[/CODE]
It's for sending the client the server test question lines.
It's a player auth not a steam auth my bad.
[editline]4th April 2017[/editline]
Okay, I understand what you guys mean now. I've hooked into it on the server but it seems like it's not firing, I put a print in and it won't print when I change jobs. I am using darkRP btw
[editline]4th April 2017[/editline]
Thanks for the help! DarkRP must override it with this, [b][url=http://wiki.darkrp.com/index.php?title=Hooks/Server/playerCanChangeTeam]playerCanChangeTeam hook[/url][/b]. I was able to get it working using the darkRP hook.
Sorry, you need to Log In to post a reply to this thread.