• Print

Author Topic: Need help with coding  (Read 18333 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.
/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

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Need help with coding
« Reply #5 on: June 27, 2015, 02:11:27 pm »
After checking the code myself, I found the solution.

Lines 47-53

Code: Lua
  1.                end
  2.             end
  3.          end
  4.       end
  5.    end
  6. end
  7. )

If you go back up and examine line 20

Code: Lua
  1. hook.Add("OnPlayerChat", "Tags", function(ply, Text, Team, PlayerIsDead)

and go downwards from there, you'll see ifs, elseifs, and fors with their corresponding ends (as seen in the first code block.)

Now, there are two solutions to this problem.

1) (lines 32-39)

Code: Lua
  1. if ply:IsPlayer() then
  2.                if ply:Alive() then
  3.                   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)
  4.                   return true
  5.                elseif !ply:Alive() then
  6.                   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)
  7.                return true -- line 38
  8.              --end <-- This is where you need to put it.
  9. end

Add another line under line 38 and enter an "end", completing the if/else.

2) Add an end on line 53 before the bracket.
Code: Lua
  1.                end
  2.             end
  3.          end
  4.       end
  5.    end
  6. end
  7. end) <--

I recommend the first solution since it keeps integrity intact, but since you're not a savvy coder you could probably do option 2.

Hope this helped!
Once you get to know me, you'll find you'll have never met me at all.

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Need help with coding
« Reply #6 on: June 29, 2015, 09:10:32 am »
Okay, so, this fixed my error, but the premium users won't have a rainbow name. (The <hsv></hsv> part)

Did I do something wrong, or is it just me?

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Need help with coding
« Reply #7 on: June 29, 2015, 10:16:20 am »
Rainbows are not possible in this version of chat tags.
Once you get to know me, you'll find you'll have never met me at all.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Need help with coding
« Reply #8 on: June 29, 2015, 11:24:00 am »
Rainbows are not possible in this version of chat tags.
His chatbox might be capable, which is where I think he's going.

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Need help with coding
« Reply #9 on: June 29, 2015, 12:17:59 pm »
His chatbox might be capable, which is where I think he's going.

Exactly what I mean.

So this is supposed to work just normally, and fine?
Or am I doing something wrong?

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Need help with coding
« Reply #10 on: June 29, 2015, 12:28:39 pm »
Exactly what I mean.

So this is supposed to work just normally, and fine?
Or am I doing something wrong?
Just skimming through it, it looks fine.  I would have to get your chatbox and test it personally.

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Need help with coding
« Reply #11 on: June 30, 2015, 08:20:44 am »
Just skimming through it, it looks fine.  I would have to get your chatbox and test it personally.
I use atlaschat, ever heard of it?

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Need help with coding
« Reply #12 on: June 30, 2015, 08:40:04 am »
I use atlaschat, ever heard of it?
Yeah, I'm actually friends with the creator, so I already have a copy.  I will check it out later today.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Need help with coding
« Reply #13 on: June 30, 2015, 09:58:05 am »
Alright so I fixed your version, you just forgot to add an "end" onto one of your statements.
Code: Lua
  1. // Client Side
  2. // Originally Made By: TyGuy
  3. // Edited By: Mr. Apple
  4.  
  5. local Tags =
  6. {
  7. --Group    --Tag     --Color
  8. {"member", "Member", Color(191, 0, 255, 255) },
  9. {"helper", "Helper", Color(0, 255, 16, 255) },
  10. {"founder", "Owner", Color(224, 31, 31, 255) },
  11. {"developer", "Developer", Color(19, 163, 11, 255) },
  12. {"moderator", "Moderator", Color(0, 169, 255, 255) },
  13. {"snrmod", "Senior Moderator", Color(0, 85, 255, 255) },
  14. {"premium", "<hsv>Premium</hsv>", Color(255, 199, 0, 255) },
  15. {"scrub", "Scrub", Color(0, 0, 0, 255) },
  16. {"superadmin", "Super Administrator", Color(225, 255, 0, 255) },
  17. {"admin", "Administrator", Color(255, 144, 0, 255) },
  18. }
  19.  
  20. hook.Add("OnPlayerChat", "Tags", function(ply, Text, Team, PlayerIsDead)
  21.         if ply:IsValid() then
  22.                 for k,v in pairs(Tags) do
  23.                         if ply:IsUserGroup(v[1]) then
  24.                                 if Team then
  25.                                                 if ply:Alive() then
  26.                                                         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)
  27.                                                 else
  28.                                                         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)
  29.                                                 end
  30.                                                 return true
  31.                                 end
  32.                                 if ply:IsPlayer() then
  33.                                         if ply:Alive() then
  34.                                                 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)
  35.                                                 return true
  36.                                         elseif !ply:Alive() then
  37.                                                 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)
  38.                                                 return true
  39.                                         end
  40.                                 end
  41.                                 if ply:IsUserGroup("premium") then
  42.                                         if ply:Alive() then
  43.                                                 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)
  44.                                                 return true
  45.                                         elseif !ply:Alive() then
  46.                                                 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)
  47.                                                 return true
  48.                                         end
  49.                                 end
  50.                         end
  51.                 end
  52.         end
  53. end)
  54.  
  55.  
  56.  
  57.  
  58.  
  59. local ADDON_NAME = "chat_prefixes"
  60. usermessage.Hook(ADDON_NAME, function(data)
  61. local Version1 = data:ReadString()
  62. local Version2 = data:ReadString()
  63. local ADDON_ACTUAL_NAME = data:ReadString()
  64. local DOWNLOAD_LINK = data:ReadString()
  65. local Frame = vgui.Create( "DFrame" )
  66. Frame:SetSize( 300, 150 )
  67. Frame:Center()
  68. Frame:SetTitle( "Addon: "..ADDON_ACTUAL_NAME.." needs updating" )
  69. Frame:SetSizable(false)
  70. Frame:SetDraggable(false)
  71. Frame:ShowCloseButton( false )
  72. Frame:MakePopup()
  73.  
  74. local FLabel = vgui.Create( "DLabel", Frame )
  75. FLabel:Center()
  76. FLabel:SetPos( 15, 27 )
  77. --FLabel:SetColor(Color(255,255,255,255)) // Color
  78. --FLabel:SetFont("default")
  79. FLabel:SetText("The addon: "..ADDON_ACTUAL_NAME.." is outdated!")
  80. FLabel:SizeToContents()
  81.  
  82. local FLabel2 = vgui.Create( "DLabel", Frame )
  83. FLabel2:Center()
  84. FLabel2:SetPos( 15, 40 )
  85. --FLabel2:SetColor(Color(255,255,255,255)) // Color
  86. --FLabel2:SetFont("default")
  87. FLabel2:SetText("Please contact system administrator to update addon!")
  88. FLabel2:SizeToContents()
  89.  
  90. local FLabel3 = vgui.Create( "DLabel", Frame )
  91. FLabel3:Center()
  92. FLabel3:SetPos( 15, 53 )
  93. --FLabel3:SetColor(Color(255,255,255,255)) // Color
  94. --FLabel3:SetFont("default")
  95. FLabel3:SetText("Server's Version:")
  96. FLabel3:SizeToContents()
  97.  
  98. local FLabel35 = vgui.Create( "DLabel", Frame )
  99. FLabel35:Center()
  100. FLabel35:SetPos( 100, 53 )
  101. FLabel35:SetColor(Color(255,0,0,255)) // Color
  102. --FLabel35:SetFont("default")
  103. FLabel35:SetText(Version1)
  104. FLabel35:SizeToContents()
  105.  
  106. local FLabel4 = vgui.Create( "DLabel", Frame )
  107. FLabel4:Center()
  108. FLabel4:SetPos( 15, 66 )
  109. --FLabel4:SetColor(Color(255,255,255,255)) // Color
  110. --FLabel4:SetFont("default")
  111. FLabel4:SetText("Online Version:")
  112. FLabel4:SizeToContents()
  113.  
  114. local FLabel45 = vgui.Create( "DLabel", Frame )
  115. FLabel45:Center()
  116. FLabel45:SetPos( 90, 66 )
  117. FLabel45:SetColor(Color(255,0,0,255)) // Color
  118. --FLabel45:SetFont("default")
  119. FLabel45:SetText(Version2)
  120. FLabel45:SizeToContents()
  121.  
  122. local FLabel5 = vgui.Create( "DLabel", Frame )
  123. FLabel5:Center()
  124. FLabel5:SetPos( 15, 81 )
  125. --FLabel5:SetColor(Color(255,255,255,255)) // Color
  126. --FLabel5:SetFont("default")
  127. FLabel5:SetText("Addon:")
  128. FLabel5:SizeToContents()
  129.  
  130. local FLabel55 = vgui.Create( "DButton", Frame )
  131. FLabel55:SetSize(ScrW() * 0.025, ScrH() * 0.015)
  132. FLabel55:Center()
  133. FLabel55:SetPos( 52, 83 )
  134. FLabel55:SetText("Link")
  135. FLabel55.DoClick = function()
  136. gui.OpenURL(DOWNLOAD_LINK)
  137. end
  138.  
  139. local Close = vgui.Create("DButton", Frame)
  140. Close:SetSize(ScrW() * 0.050, ScrH() * 0.025)
  141. Close:Center()
  142. Close:SetPos(105,120)
  143. Close:SetText("Ok")
  144. Close.DoClick = function()
  145. if Checkbox:GetChecked() == true then
  146. net.Start( ADDON_NAME )
  147.         net.WriteEntity(LocalPlayer())
  148. net.SendToServer()
  149. end
  150. end
  151.  
  152. local Checkbox = vgui.Create( "DCheckBox", Frame )
  153. Checkbox:Center()
  154. Checkbox:SetPos( 65, 105 )
  155. Checkbox:SetChecked( false )
  156.  
  157. local FLabel6 = vgui.Create( "DLabel", Frame )
  158. FLabel6:Center()
  159. FLabel6:SetPos( 85, 105 )
  160. FLabel6:SetColor(Color(255,0,0,255)) // Color
  161. FLabel6:SetFont("default")
  162. FLabel6:SetText("Never show message again!")
  163. FLabel6:SizeToContents()
  164.  
  165. local Close = vgui.Create("DButton", Frame)
  166. Close:SetSize(ScrW() * 0.050, ScrH() * 0.025)
  167. Close:Center()
  168. Close:SetPos(105,120)
  169. Close:SetText("Ok")
  170. Close.DoClick = function()
  171. if Checkbox:GetChecked() == true then
  172. net.Start( ADDON_NAME )
  173.         net.WriteEntity(LocalPlayer())
  174. net.SendToServer()
  175. end
  176.         Frame:Close()
  177. end
  178. end)

Then I also went ahead and cleaned it up a bit (I really don't know if this is better way to do it or not, but it is cleaner).



EDIT:  I guess I thought doing the name was what you were looking for more so, but it is easily edited (\/ \/ \/).  Just add another group check like I did for the name.

Code: Lua
  1. // client side apple
  2.  
  3. local hsv_tags = {
  4.         "superadmin"
  5. }
  6.  
  7. function ChatTags(ply, Text, Team, PlayerIsDead)
  8.         local addchat = {Color(255, 0, 0, 255)}
  9.  
  10.         if ply:IsPlayer() then
  11.                 if !ply:Alive() then
  12.                         table.insert(addchat, "*DEAD* ")
  13.                 end
  14.         end
  15.         if Team then
  16.                 table.insert(addchat, "(TEAM) ")
  17.         end
  18.  
  19.         local teamcolor = team.GetColor(ply:Team())
  20.         local teamnick = team.GetName(ply:Team())
  21.  
  22.         table.insert(addchat, teamcolor)
  23.         table.insert(addchat, teamnick)
  24.         table.insert(addchat, Color(50, 50, 50, 255))
  25.         table.insert(addchat, "| ")  
  26.  
  27.         if table.HasValue(hsv_tags, ply:GetUserGroup()) then
  28.                 table.insert(addchat, "<hsv>"..ply:Nick() .."</hsv>")
  29.         else
  30.                 table.insert(addchat, teamcolor)
  31.                 table.insert(addchat, ply:Nick())
  32.         end
  33.  
  34.         table.insert(addchat, Color(255, 255, 255, 255))
  35.         table.insert(addchat, ": "..Text)
  36.  
  37.         chat.AddText(unpack(addchat))
  38.         return true
  39. end
  40. hook.Add("OnPlayerChat", "Tags", ChatTags)
  41.  
  42. local ADDON_NAME = "chat_prefixes"
  43. usermessage.Hook(ADDON_NAME, function(data)
  44. local Version1 = data:ReadString()
  45. local Version2 = data:ReadString()
  46. local ADDON_ACTUAL_NAME = data:ReadString()
  47. local DOWNLOAD_LINK = data:ReadString()
  48. local Frame = vgui.Create( "DFrame" )
  49. Frame:SetSize( 300, 150 )
  50. Frame:Center()
  51. Frame:SetTitle( "Addon: "..ADDON_ACTUAL_NAME.." needs updating" )
  52. Frame:SetSizable(false)
  53. Frame:SetDraggable(false)
  54. Frame:ShowCloseButton( false )
  55. Frame:MakePopup()
  56.  
  57. local FLabel = vgui.Create( "DLabel", Frame )
  58. FLabel:Center()
  59. FLabel:SetPos( 15, 27 )
  60. --FLabel:SetColor(Color(255,255,255,255)) // Color
  61. --FLabel:SetFont("default")
  62. FLabel:SetText("The addon: "..ADDON_ACTUAL_NAME.." is outdated!")
  63. FLabel:SizeToContents()
  64.  
  65. local FLabel2 = vgui.Create( "DLabel", Frame )
  66. FLabel2:Center()
  67. FLabel2:SetPos( 15, 40 )
  68. --FLabel2:SetColor(Color(255,255,255,255)) // Color
  69. --FLabel2:SetFont("default")
  70. FLabel2:SetText("Please contact system administrator to update addon!")
  71. FLabel2:SizeToContents()
  72.  
  73. local FLabel3 = vgui.Create( "DLabel", Frame )
  74. FLabel3:Center()
  75. FLabel3:SetPos( 15, 53 )
  76. --FLabel3:SetColor(Color(255,255,255,255)) // Color
  77. --FLabel3:SetFont("default")
  78. FLabel3:SetText("Server's Version:")
  79. FLabel3:SizeToContents()
  80.  
  81. local FLabel35 = vgui.Create( "DLabel", Frame )
  82. FLabel35:Center()
  83. FLabel35:SetPos( 100, 53 )
  84. FLabel35:SetColor(Color(255,0,0,255)) // Color
  85. --FLabel35:SetFont("default")
  86. FLabel35:SetText(Version1)
  87. FLabel35:SizeToContents()
  88.  
  89. local FLabel4 = vgui.Create( "DLabel", Frame )
  90. FLabel4:Center()
  91. FLabel4:SetPos( 15, 66 )
  92. --FLabel4:SetColor(Color(255,255,255,255)) // Color
  93. --FLabel4:SetFont("default")
  94. FLabel4:SetText("Online Version:")
  95. FLabel4:SizeToContents()
  96.  
  97. local FLabel45 = vgui.Create( "DLabel", Frame )
  98. FLabel45:Center()
  99. FLabel45:SetPos( 90, 66 )
  100. FLabel45:SetColor(Color(255,0,0,255)) // Color
  101. --FLabel45:SetFont("default")
  102. FLabel45:SetText(Version2)
  103. FLabel45:SizeToContents()
  104.  
  105. local FLabel5 = vgui.Create( "DLabel", Frame )
  106. FLabel5:Center()
  107. FLabel5:SetPos( 15, 81 )
  108. --FLabel5:SetColor(Color(255,255,255,255)) // Color
  109. --FLabel5:SetFont("default")
  110. FLabel5:SetText("Addon:")
  111. FLabel5:SizeToContents()
  112.  
  113. local FLabel55 = vgui.Create( "DButton", Frame )
  114. FLabel55:SetSize(ScrW() * 0.025, ScrH() * 0.015)
  115. FLabel55:Center()
  116. FLabel55:SetPos( 52, 83 )
  117. FLabel55:SetText("Link")
  118. FLabel55.DoClick = function()
  119. gui.OpenURL(DOWNLOAD_LINK)
  120. end
  121.  
  122. local Close = vgui.Create("DButton", Frame)
  123. Close:SetSize(ScrW() * 0.050, ScrH() * 0.025)
  124. Close:Center()
  125. Close:SetPos(105,120)
  126. Close:SetText("Ok")
  127. Close.DoClick = function()
  128. if Checkbox:GetChecked() == true then
  129. net.Start( ADDON_NAME )
  130.         net.WriteEntity(LocalPlayer())
  131. net.SendToServer()
  132. end
  133. end
  134.  
  135. local Checkbox = vgui.Create( "DCheckBox", Frame )
  136. Checkbox:Center()
  137. Checkbox:SetPos( 65, 105 )
  138. Checkbox:SetChecked( false )
  139.  
  140. local FLabel6 = vgui.Create( "DLabel", Frame )
  141. FLabel6:Center()
  142. FLabel6:SetPos( 85, 105 )
  143. FLabel6:SetColor(Color(255,0,0,255)) // Color
  144. FLabel6:SetFont("default")
  145. FLabel6:SetText("Never show message again!")
  146. FLabel6:SizeToContents()
  147.  
  148. local Close = vgui.Create("DButton", Frame)
  149. Close:SetSize(ScrW() * 0.050, ScrH() * 0.025)
  150. Close:Center()
  151. Close:SetPos(105,120)
  152. Close:SetText("Ok")
  153. Close.DoClick = function()
  154. if Checkbox:GetChecked() == true then
  155. net.Start( ADDON_NAME )
  156.         net.WriteEntity(LocalPlayer())
  157. net.SendToServer()
  158. end
  159.         Frame:Close()
  160. end
  161. end)

Feel absolutely free to request I take this down apple.
« Last Edit: June 30, 2015, 01:38:28 pm by Aaron113 »

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Need help with coding
« Reply #14 on: July 01, 2015, 08:09:27 am »
So what do I do with the second code?
(Sorry, I'm probaly stupid :P)

  • Print