DarkRP Chat commands

I want to learn how to make commands that goto certin jobs e.g /cab <message> That then goes to any one online which is TEAM_CAB, where should i start or what should i do?

well, i would make something for you but I’m not on my computer at this second.

Roughly, this is the way you’ll do it:

Start off with the PlayerSay hook, then determining it has the words “/cab” in it.

scan for every player ( the player.GetAll table ) and see if that players team = TEAM_CAB. Then you might math.Random a key in that table.

Get that player’s position and set your players position by Player:SetPos( OtherPlayer:GetEyePos():Forward * 2 or something)

end the functions

Ok that makes sense but when you get to your computer would you be able to help me a bit more like where to put it ect

server

?

autorun/server/

no

I woulda spoon fed you, but Exploderguy already told you everything you need to know.

Now its your turn. Do what Exploderguy said, and put all of that in autorun/server

Oh heres another tip, try gooling playersay hook, you’ll get 2 examples.

i cant find the Play.GetALL table



//server
util.AddNetworkString( "send_to_cab" )

function googling_playersay_hook_and_networking_is_hard( ply, text )

	if ( text:sub( 1, 4 ) == "/cab" ) then
		
		for k,v in pairs( player.GetAll() ) do

			if ( v:Team() == TEAM_CAB ) then

				net.Start( "send_to_cab" )
					net.WriteString( sub:text( 6 ) )
				net.Send( v )

			end
			
		end

	end

end
hook.Add( "PlayerSay", "google", googling_playersay_hook_and_networking_is_hard )

//client
net.Receive( "send_to_cab", function( len, ply )

	local cab = net.ReadString()

	chat.AddText( Color( 255, 255, 255, 255 ), cab )

end )


sry for any errors, quickly wrote it up.

so where should i put this autorun/server/? And what file name?

File name: dbuomrbris.lua

Use whatever filename you want

But id suggest making a folder inside of addons and name it whatever
then put a lua folder inside of the whatever folder
then put a autorun folder inside of the lua folder
then put a client folder inside of the autorun folder
then put a server folder inside of the autorun folder
then put the serverside code inside of the server side folder, and put the client side code inside of the client side folder.

But what you made is not a chat command?

Yes? Did you look at the code? Did you try it?