DarkRP where to put functions

Hey, i’ve written some functions i want to work with DarkRP, and i can find where to put them so they work. If it helps ill include the functions below:



local function GiveFists( ply )
	if ply:Team() == TEAM_DUEL then
		local LookingAt = ply:GetEyeTrace().Entity
		if not ValidEntity(LookingAt) or not LookingAt:IsPlayer() or LookingAt:GetPos():Distance(ply:GetPos()) > 100 then
			Notify(ply, 1, 4, string.format(LANGUAGE.must_be_looking_at, "player"))
			return ""
		end
		LookingAt:Give("weapon_mad_fists")
		LookingAt:PrintMessage(HUD_PRINTTALK, "You have been given some fists!")
		ply:PrintMessage(HUD_PRINTTALK, "You have given "..LookingAt.." some fists!")
	end
end
AddChatCommand("/givefists", GiveFists)

local function AppSS( ply )
	if ply:Team() == TEAM_MAYOR then
		local LookingAt = ply:GetEyeTrace().Entity
		if not ValidEntity(LookingAt) or not LookingAt:IsPlayer() or LookingAt:GetPos():Distance(ply:GetPos()) > 100 then
			Notify(ply, 1, 4, string.format(LANGUAGE.must_be_looking_at, "player"))
			return ""
		end
		LookingAt:ChangeTeam( TEAM_MG, true )
		ply:PrintMessage(HUD_PRINTTALK, "You have made "..LookingAt.." a secret service agent!"
	end
end
AddChatCommand("/makess", AppSS)


It depends, if you’re going to write a HUD, it goes to cl_hud.lua, if you’re writing a new tab or something, it goes to cl_vgui.lua… Get the point? Judging by your code, it goes to shared.lua

I can just drop this at the end of shared.lua without errors? And currently no plan to made huds or tabs.

Whoops, I meant at player.lua, that code should belong somewhere in line 243

Thanks for the help, one last question. Do i remove the functions themselves and just throw the code in? or can i put the functions whole at around line 243 under the changeteam function?

Add all the functions in, I don’t think it would be a huge problem.

I put it in player.lua and it kinda fucked it up. I think the problem is that these are completely independent functions that i want to be triggered by a chat command instead of when they change teams. Where would i just put generic functions that have their own trigger?