a nil value

sv_misc.lua:223: attempt to call global ‘addchatcommand’ <a nil value>
sv_items.lua:138: attempt to call global ‘addchatcommand’ <a nil value>
sv_chat.lua:52: attempt to call global ‘addchatcommand’ <a nil value>
commands_admin.lua:6: attempt to call global ‘addchatcommand’ <a nil value>
commands_mayor.lua:27: attempt to call global ‘addchatcommand’ <a nil value>

anyone knows how to fix this?
thank you.

Are you sure the case is exactly right? It may be AddChatCommand rather than just addchatcommand.

Without knowing what kind of environment you’re running I can’t fix it. It looks like you’re trying to use an addchatcommand function which doesn’t exist. It’s not a standard garrysmod function so it’d either have to be defined elsewhere in your code or you’re using a function which was defined as part of another addon.
If the case is correct then either the scope or the execution order is wrong.
Scope being if you made the function local in one file but use it in another.
Execution order being if the file which defines the addchatcommand function is loaded after the files which use it.

I think DarkRP has a chat command system with AddChatCommand to register one. The commands_mayor thing suggests he’s trying to alter some RP gamemode.