ive been working on a gamemode and this is the ooc system that is used by the gamemode
[CODE]
-- Chat system
local gKeys = {}
gKeys["/"] = {}
gKeys["/"]["ooc"] = function( ply, text, tc, isDead, space )
if ply:GetUserGroup() == "developer" then
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 50, 50, 230 ),
"[Dev] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
else
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
end
end
gKeys["/"]["g"] = gKeys["/"]["ooc"]
gKeys["/"]["y"] = gKeys["/"]["ooc"]
gKeys["/"]["/"] = gKeys["/"]["ooc"]
gKeys["!"] = {}
gKeys["!"]["ooc"] = function( ply, text, tc, isDead, space )
if ply:GetUserGroup() == "developer" then
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 50, 50, 230 ),
"[Dev] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
else
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
end
end
gKeys["!"]["g"] = gKeys["!"]["ooc"]
gKeys["!"]["y"] = gKeys["!"]["ooc"]
[/CODE]
With this ooc system when i try to set multiple ulx groups for chat tags it receive an error.
hopfully someone can help me use multiple chat tags with this ooc system and thanks in advance.
What error?
You should find a better way of doing this. There's so much reused code.
This what i tried to add multiple chat tags
[code]
local gKeys = {}
gKeys["/"] = {}
gKeys["/"]["ooc"] = function( ply, text, tc, isDead, space )
if ply:GetUserGroup() == "developer" then
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 50, 50, 230 ),
"[Dev] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
or
if ply:GetUserGroup() == "moderator" then
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 50, 230, 50 ),
"[M] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
else
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
end
end
gKeys["/"]["g"] = gKeys["/"]["ooc"]
gKeys["/"]["y"] = gKeys["/"]["ooc"]
gKeys["/"]["/"] = gKeys["/"]["ooc"]
gKeys["!"] = {}
gKeys["!"]["ooc"] = function( ply, text, tc, isDead, space )
if ply:GetUserGroup() == "developer" then
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 50, 50, 230 ),
"[Dev] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
or
if ply:GetUserGroup() == "moderator" then
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 50, 230, 50 ),
"[M] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
else
chat.AddText( Color( 100, 100, 100 ),
"[OOC] ",
Color( 180, 180, 180 ),
ply:Nick() .. ": ",
Color( 230, 230, 230 ),
string.sub( text, space + 1 ) )
end
end
gKeys["!"]["g"] = gKeys["!"]["ooc"]
gKeys["!"]["y"] = gKeys["!"]["ooc"]
[/code]
This is the error i received
[ERROR] gamemodes/dayz/gamemode/cl_init.lua:116: unexpected symbol near 'or'
1. unknown - gamemodes/dayz/gamemode/cl_init.lua:0
Use else if instead. Or is if you have if (this or that) then do this end
Also, you should setup your chat tags in a table and to be index like
[code]
local tags = {}
tags['user']
tags['developer'] = {Color(1, 2, 3) ,'DEV'}
tags['moderator'] = {Color(4, 5, 6), 'M'}
[/code]
And then grab them like this
[code]
local chatTagData = tags[ply:GetNWString("usergroup")]
local col, prefix = chatTagData[1], chatTagData[2]
[/code]
Also, like man with hat said, you really should consider redoing your chat command structure, it's very repetitive.
[QUOTE=crazyscouter;50811804]Use else if instead. Or is if you have if (this or that) then do this end
Also, you should setup your chat tags in a table and to be index like
[code]
local tags = {}
tags['user']
tags['developer'] = {Color(1, 2, 3) ,'DEV'}
tags['moderator'] = {Color(4, 5, 6), 'M'}
[/code]
And then grab them like this
[code]
local chatTagData = tags[ply:GetNWString("usergroup")]
local col, prefix = chatTagData[1], chatTagData[2]
[/code]
Also, like man with hat said, you really should consider redoing your chat command structure, it's very repetitive.[/QUOTE]
Allright ill work on that.
Edit : tried else if didnt work got error
[ERROR] gamemodes/dayz/gamemode/cl_init.lua:574: 'end' expected (to close 'function' at line 140) near '<eof>'
1. unknown - gamemodes/dayz/gamemode/cl_init.lua:0
This is the code i tried with else if
Edit again i used elseif wrong xd
Sorry, you need to Log In to post a reply to this thread.