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 [URL="https://github.com/FPtje/darkrpmodification"]here[/URL] by creating your own custom module.
You can find functions to help you with creating commands on the DarkRP wiki, [URL="http://wiki.darkrp.com/index.php/Category:Functions"]here[/URL].
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.
[QUOTE=Kevin Adams;49731514]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 [URL="https://github.com/FPtje/darkrpmodification"]here[/URL] by creating your own custom module.
You can find functions to help you with creating commands on the DarkRP wiki, [URL="http://wiki.darkrp.com/index.php/Category:Functions"]here[/URL].
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.[/QUOTE]
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
[CODE]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)[/CODE]
Then, in garrysmod/gamemodes/darkrp/gamemode/modules/chat/sh_commands.lua replace the advert command with
[CODE]DarkRP.declareChatCommand{
command = "announce",
description = "Advertise something to everyone in the server.",
delay = 30.0
}[/CODE]
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.
[QUOTE=Kevin Adams;49731662]First, replace the PlayerAdvertise function in garrysmod/gamemodes/darkrp/gamemode/modules/chat/sv_commands.lua with
[CODE]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)[/CODE]
Then, in garrysmod/gamemodes/darkrp/gamemode/modules/chat/sh_commands.lua replace the advert command with
[CODE]DarkRP.declareChatCommand{
command = "announce",
description = "Advertise something to everyone in the server.",
delay = 30.0
}[/CODE]
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.[/QUOTE]
Thanks! I simply put a timer.Simple around the for block.
[CODE]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)[/CODE]
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.
Sorry, you need to Log In to post a reply to this thread.