ULX

Author Topic: Need help with coding  (Read 7182 times)

0 Members and 1 Guest are viewing this topic.

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Need help with coding
« on: June 27, 2015, 06:34:38 AM »
So I didn't really know where to go with this and have tryed several sites for answer about lua coding, and now I'm here, hoping someone can find a solution for me, as I'm not very familiar with lua, knowing only the basics, which probaly isn't enough, I keep getting this error, as I'm tyring to adjust some things in this addon I downloaded from the internet.

Code: [Select]
// Client Side
// Originally Made By: TyGuy
// Edited By: Mr. Apple

local Tags =
{
--Group    --Tag     --Color
{"member", "Member", Color(191, 0, 255, 255) },
{"helper", "Helper", Color(0, 255, 16, 255) },
{"founder", "Owner", Color(224, 31, 31, 255) },
{"developer", "Developer", Color(19, 163, 11, 255) },
{"moderator", "Moderator", Color(0, 169, 255, 255) },
{"snrmod", "Senior Moderator", Color(0, 85, 255, 255) },
{"premium", "<hsv>Premium</hsv>", Color(255, 199, 0, 255) },
{"scrub", "Scrub", Color(0, 0, 0, 255) },
{"superadmin", "Super Administrator", Color(225, 255, 0, 255) },
{"admin", "Administrator", Color(255, 144, 0, 255) },
}

hook.Add("OnPlayerChat", "Tags", function(ply, Text, Team, PlayerIsDead)
if ply:IsValid() then
for k,v in pairs(Tags) do
if ply:IsUserGroup(v[1]) then
if Team then
if ply:Alive() then
chat.AddText(Color(0, 204, 0, 255), "{TEAM} ", Color(50, 50, 50, 255), "[", v[3], v[2], Color(50, 50, 50, 255), "] ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
else
chat.AddText(Color(255, 0, 0, 255), "*DEAD*", Color(0, 204, 0, 255), "{TEAM} ", Color(50, 50, 50, 255), "[", v[3], v[2], Color(50, 50, 50, 255), "] ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
end
return true
end
if ply:IsPlayer() then
if ply:Alive() then
chat.AddText(Color(50, 50, 50, 255), "[", v[3], v[2], Color(50, 50, 50, 255), "] ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
return true
elseif !ply:Alive() then
chat.AddText(Color(255, 0, 0, 255), "*DEAD* ", Color(50, 50, 50, 255), "[", v[3], v[2], Color(50, 50, 50, 255), "] ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
return true
end
if ply:IsUserGroup("premium") then
if ply:Alive() then
chat.AddText(Color(50, 50, 50, 255), "[", v[3], v[3], Color(50, 50, 50, 255), "] ", v[3], "<hsv>", ply:Nick(), "</hsv>", color_white, ": ", Color(255, 255, 255, 255), Text)
return true
elseif !ply:Alive() then
chat.AddText(Color(255, 0, 0, 255), "*DEAD* ", Color(50, 50, 50, 255), "[", v[3], v[3], Color(50, 50, 50, 255), "] ", v[3], "<hsv>", ply:Nick(), "</hsv>", color_white, ": ", Color(255, 255, 255, 255), Text)
return true
end
end
end
end
end
end
)





local ADDON_NAME = "chat_prefixes"
usermessage.Hook(ADDON_NAME, function(data)
local Version1 = data:ReadString()
local Version2 = data:ReadString()
local ADDON_ACTUAL_NAME = data:ReadString()
local DOWNLOAD_LINK = data:ReadString()
local Frame = vgui.Create( "DFrame" )
Frame:SetSize( 300, 150 )
Frame:Center()
Frame:SetTitle( "Addon: "..ADDON_ACTUAL_NAME.." needs updating" )
Frame:SetSizable(false)
Frame:SetDraggable(false)
Frame:ShowCloseButton( false )
Frame:MakePopup()

local FLabel = vgui.Create( "DLabel", Frame )
FLabel:Center()
FLabel:SetPos( 15, 27 )
--FLabel:SetColor(Color(255,255,255,255)) // Color
--FLabel:SetFont("default")
FLabel:SetText("The addon: "..ADDON_ACTUAL_NAME.." is outdated!")
FLabel:SizeToContents()

local FLabel2 = vgui.Create( "DLabel", Frame )
FLabel2:Center()
FLabel2:SetPos( 15, 40 )
--FLabel2:SetColor(Color(255,255,255,255)) // Color
--FLabel2:SetFont("default")
FLabel2:SetText("Please contact system administrator to update addon!")
FLabel2:SizeToContents()

local FLabel3 = vgui.Create( "DLabel", Frame )
FLabel3:Center()
FLabel3:SetPos( 15, 53 )
--FLabel3:SetColor(Color(255,255,255,255)) // Color
--FLabel3:SetFont("default")
FLabel3:SetText("Server's Version:")
FLabel3:SizeToContents()

local FLabel35 = vgui.Create( "DLabel", Frame )
FLabel35:Center()
FLabel35:SetPos( 100, 53 )
FLabel35:SetColor(Color(255,0,0,255)) // Color
--FLabel35:SetFont("default")
FLabel35:SetText(Version1)
FLabel35:SizeToContents()

local FLabel4 = vgui.Create( "DLabel", Frame )
FLabel4:Center()
FLabel4:SetPos( 15, 66 )
--FLabel4:SetColor(Color(255,255,255,255)) // Color
--FLabel4:SetFont("default")
FLabel4:SetText("Online Version:")
FLabel4:SizeToContents()

local FLabel45 = vgui.Create( "DLabel", Frame )
FLabel45:Center()
FLabel45:SetPos( 90, 66 )
FLabel45:SetColor(Color(255,0,0,255)) // Color
--FLabel45:SetFont("default")
FLabel45:SetText(Version2)
FLabel45:SizeToContents()

local FLabel5 = vgui.Create( "DLabel", Frame )
FLabel5:Center()
FLabel5:SetPos( 15, 81 )
--FLabel5:SetColor(Color(255,255,255,255)) // Color
--FLabel5:SetFont("default")
FLabel5:SetText("Addon:")
FLabel5:SizeToContents()

local FLabel55 = vgui.Create( "DButton", Frame )
FLabel55:SetSize(ScrW() * 0.025, ScrH() * 0.015)
FLabel55:Center()
FLabel55:SetPos( 52, 83 )
FLabel55:SetText("Link")
FLabel55.DoClick = function()
gui.OpenURL(DOWNLOAD_LINK)
end

local Close = vgui.Create("DButton", Frame)
Close:SetSize(ScrW() * 0.050, ScrH() * 0.025)
Close:Center()
Close:SetPos(105,120)
Close:SetText("Ok")
Close.DoClick = function()
if Checkbox:GetChecked() == true then
net.Start( ADDON_NAME )
net.WriteEntity(LocalPlayer())
net.SendToServer()
end
end

local Checkbox = vgui.Create( "DCheckBox", Frame )
Checkbox:Center()
Checkbox:SetPos( 65, 105 )
Checkbox:SetChecked( false )

local FLabel6 = vgui.Create( "DLabel", Frame )
FLabel6:Center()
FLabel6:SetPos( 85, 105 )
FLabel6:SetColor(Color(255,0,0,255)) // Color
FLabel6:SetFont("default")
FLabel6:SetText("Never show message again!")
FLabel6:SizeToContents()

local Close = vgui.Create("DButton", Frame)
Close:SetSize(ScrW() * 0.050, ScrH() * 0.025)
Close:Center()
Close:SetPos(105,120)
Close:SetText("Ok")
Close.DoClick = function()
if Checkbox:GetChecked() == true then
net.Start( ADDON_NAME )
net.WriteEntity(LocalPlayer())
net.SendToServer()
end
Frame:Close()
end
end)

Now here's my error and I don't know what I'm doing wrong,

Code: [Select]
[ERROR] addons/apple_manage_chat_tags/lua/autorun/cl_chat_apple_tag.lua:54: unexpected symbol near ')'
  1. unknown - addons/apple_manage_chat_tags/lua/autorun/cl_chat_apple_tag.lua:0

 I only want the user group premium to have a rainbow colored name, which I can do by doing <hsv></hsv> and put something in it like
<hsv>ThisIsMyUserName</hsv> but this addon keeps giving me errors, and I think I'm probaly doing something wrong in the code, and don't know the solution, if any of you could teach me how to do it correctly to make it work, or give me a good version of my code, I would appreciate it, like so badly!

Greetings, Dogey. (AKA Janjakob2000)

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Need help with coding
« Reply #1 on: June 27, 2015, 08:24:57 AM »
The release thread for this addon is actually in our Releases section.

Error stack traces from Gmod can be sometimes cryptic, but, they're almost always good enough to tell you the line number something went wrong in the first line of stack.
Your error is telling you a symbol is at or near line 54 in the file that Lua saw and went "uh, what? Why is this here?!"

Get a text editor that shows line numbers. (I personally use Notepad++, but, there are many)
Paste that code into it, or open the file using it.
Look at line 54 as the error explains.

You have a ) "close parenthesis" somehow at line 53.
Remove it.
Go from there.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Need help with coding
« Reply #2 on: June 27, 2015, 08:31:02 AM »
Removed it, addon broken.
(the addon doesn't work anymore)

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Need help with coding
« Reply #3 on: June 27, 2015, 09:31:19 AM »
Is there any fix for this? :c

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Need help with coding
« Reply #4 on: June 27, 2015, 11:00:39 AM »
First, telling anyone it's broken is kind of null and void.
It works for many people or Mr Apple would likely ask us to remove it, as he's quite active in his Release thread like I mentioned.
http://forums.ulyssesmod.net/index.php/topic,6196.0.html
Make sure you're using the latest version of his code. You said you downloaded "from the internet"...that could be anywhere but proper/latest.

What error occurs now?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given