• Comms Not Working?
    3 replies, posted
Hello, I was working on adding a Comms function on my StarwarsRP server, and this is what I got. [CODE] local function PlayerComms(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, DarkRP.getPhrase("[Comms]") .. " " .. ply:Nick(), Color(255, 250, 162, 255), text, ply) end end return args, DoSay end DarkRP.defineChatCommand("comms", PlayerComms, 1.5) [/CODE] This is placed inside /gamemodes/starwarsrp/gamemode/modules/chat/sh_chaatcommands.lua I also have the following in the same file: [CODE] DarkRP.declareChatCommand{ command = "comms", description = "Use Communications", delay = 1.5 } [/CODE] [editline]30th October 2017[/editline] It isnt working. The LUA error is; [QUOTE][ERROR] gamemodes/starwarsrp/gamemode/modules/chat/sh_chatcommands.lua:82: attempt to call field 'defineChatCommand' (a nil value) 1. unknown - gamemodes/starwarsrp/gamemode/modules/chat/sh_chatcommands.lua:82 2. include - [C]:-1 3. LoadModules - gamemodes/starwarsrp/gamemode/cl_init.lua:21 4. unknown - gamemodes/starwarsrp/gamemode/cl_init.lua:46 [/QUOTE] Am I doing something wrong? (Just added this to the main post so you dont have to scroll to see it)
[QUOTE=Shendow;52838200]What's your issue? You just posted your code. [editline]30th October 2017[/editline] If the issue is about your command not existing, you can try adding a print in your file and see if it's being ran.[/QUOTE] I found the LUA error, the error is as follows. [QUOTE][ERROR] gamemodes/starwarsrp/gamemode/modules/chat/sh_chatcommands.lua:82: attempt to call field 'defineChatCommand' (a nil value) 1. unknown - gamemodes/starwarsrp/gamemode/modules/chat/sh_chatcommands.lua:82 2. include - [C]:-1 3. LoadModules - gamemodes/starwarsrp/gamemode/cl_init.lua:21 4. unknown - gamemodes/starwarsrp/gamemode/cl_init.lua:46 [/QUOTE]
Chat commands in DarkRP must be defined serverside. Just make a new file called sv_chatcommands and add the chat command serverside. Make sure you KEEP the declareChatCommand shared, however.
Sorry, you need to Log In to post a reply to this thread.