I coded my own chat commands for !discord (opens discord link) and then !servergroup (opens server group). I ran it through the lua check but it says its perfect, but there are lua errors in the server
Code:
local function OpenDiscordPage(ply, text, team)
if string.sub( text, 1, 8 ) == "!discord" then
ply:SendLua( [[gui.OpenURL("https://discordapp.com/channels/513500414440898561/513513534026678274") ]] )
end
end
hook.add("playerSay", "OpenDiscordPage", OpenDiscordPage )
local function OpenServerGroupPage(ply, text, team)
if string.sub( text, 1, 8 ) == "!servergroup" then
ply:SendLua( [[gui.OpenURL("https://steamcommunity.com/groups/grizzlygaming93") ]] )
end
end
hook.add("playerSay", "OpenServerGroupPage", OpenServerGroupPage )
Lua error:
[ERROR] A runtime error has occurred in "addons/darkrpmodification/lua/darkrp_modules/commands/sv_commands.lua" on line 8.
The best help I can give you is this:
'add' is being called like it is a function, but in reality it does not exist (is nil).
Hints:
- You are doing either stuff.something(<otherstuff>) or stuff:something(<otherstuff>). The 'something' here does not exist.
The responsibility for the error above lies with (the authors of) one (or more) of these files:
1. addons/darkrpmodification/lua/darkrp_modules/commands/sv_commands.lua on line 8
2. gamemodes/darkrp/gamemode/libraries/fn.lua on line 84
3. gamemodes/darkrp/gamemode/libraries/fn.lua on line 84
4. gamemodes/darkrp/gamemode/libraries/modificationloader.lua on line 92
5. gamemodes/darkrp/gamemode/libraries/modificationloader.lua on line 147
6. gamemodes/darkrp/gamemode/init.lua on line 111
------- End of Simplerr error -------
You need to replace 'hook.add' with 'hook.Add',
After i did that. it fixed the lua error, but nothing happens when i type the command
It would be smarter to run these as ULX commands if you are running ulx.
the !servergroup one wont work because you're checking the first 8 characters but "!servergroup" is way more than 8 characters. not sure why !discord wouldnt be working
Your hook name is also incorrect, it should be "PlayerSay".
it works thanks! but when I type it in a link pops up real quick but opens my esc menu before i can do anything how will i do that
Sorry, you need to Log In to post a reply to this thread.