DarkRP Editing Chat commands

I’m working on my own custom gamemode (BMRP), and I have no clue where to find the original code for the chat commands in-order to edit them to my liking. I tried looking all over the module folder, and came up with nothing.

If someone could post the code for all the chat commands, and how to edit them correctly, that would be highly appreciated.

Depends on the type of command you’re looking to edit, if you plan to actually change the functions.

You can add new chat commands to DarkRP here: garrysmod/gamemodes/darkrp/gamemode/modules/base/sh_commands.lua

To edit the functions of certain commands, you can find the folder that related to them in the darkrp/gamemode/modules section. For example, you can edit /wanted in /darkrp/gamemode/models/police/sv_commands.lua

If you plan on adding your own new commands, I’d suggest you do it in the darkrp modifications addon found here by creating your own custom module.

You can find functions to help you with creating commands on the DarkRP wiki, here.

If you have a specific command in mind, let me know and I’ll try to give you some tips on how it’d work.

I’m trying to look for the command advert. And thanks for replying

[editline]13th February 2016[/editline]

To be a little more descriptive, I want to change the advert chat tag and command to Announce and add a 30 second delay to it.

First, replace the PlayerAdvertise function in garrysmod/gamemodes/darkrp/gamemode/modules/chat/sv_commands.lua with


local function PlayerAdvertise(ply, args)
    if args == "" then
        DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
        return ""
    end
    local DoSay = function(text)
        if text == "" then
            DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
            return
        end
        for k,v in pairs(player.GetAll()) do
            local col = team.GetColor(ply:Team())
            DarkRP.talkToPerson(v, col, "[Announcement]" .. " " .. ply:Nick(), Color(255, 255, 0, 255), text, ply)
        end
    end
    return args, DoSay
end
DarkRP.defineChatCommand("announce", PlayerAdvertise, 30.0)

Then, in garrysmod/gamemodes/darkrp/gamemode/modules/chat/sh_commands.lua replace the advert command with


DarkRP.declareChatCommand{
    command = "announce",
    description = "Advertise something to everyone in the server.",
    delay = 30.0
}

DarkRP by default has a delay parameter which makes it so the player cannot execute the command again for 30 seconds, if you meant having the player type the command and then have the server wait 30 seconds before executing it you’d have to add that in.

Thanks! I simply put a timer.Simple around the for block.


local function PlayerAdvertise(ply, args)
	if args == "" then
		DarkRP.notify(ply, 0, 7, DarkRP.getPhrase("invalid_x", "argument", ""))
		return ""
	end
	local DoSay = function(text)
		if text == "" then
			DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
			return
		end
		DarkRP.notify(ply, 1, 4, "Your announcement will be displayed shortly")
		timer.Simple(30, function()
			for k,v in pairs(player.GetAll()) do
				local col = team.GetColor(ply:Team())
				DarkRP.talkToPerson(v, col,  "[Announcement]"..ply:Nick(), Color(255,255,0,255), text, ply)
			end 
		end )
	end
	return args, DoSay
end
DarkRP.defineChatCommand("announce", PlayerAdvertise, 5)

I’m guessing to remove chat commands you can simply use DarkRP.removeChatCommand() without having to edit them out?

Yeah, using DarkRP.removeChatCommand( name ) should remove it.