How would I get a table's key from the value? Or rather an alternative way to do this
Basically, I want to pick x things from a SHARED table - serverside so they're the same for all - then give it to the client, this is essentially what I have:
[code]
local fulltable = {
["key"] = "value",
["key1"] = "value1",
["key2"] = "value2",
["key3"] = "value3",
["key4"] = "value4",
["key5"] = "value5"
}
local tbl = {}
for i=1,3 do
local pick = table.Random(fulltable)
table.insert(tbl, pick)
end
net.Start("example")
net.WriteTable(tbl)
net.Broadcast()
[/code]
But when I read the table clientside, the value is read fine but the key isn't sent, so it's 1,2,3,4,5, etc and while this isn't the end of the world - I would like to get this working so a solution to my issue would be greatly appreciated, ty!
[QUOTE=NiandraLades;49117995]How would I get a table's key from the value? Unless I'm forgetting a better way to do this
Basically, I want to pick x things from a table - serverside so they're the same for all - then give it to the client, this is essentially what I have:
[code]
local fulltable = {
["key"] = "value",
["key1"] = "value1",
["key2"] = "value2",
["key3"] = "value3",
["key4"] = "value4",
["key5"] = "value5"
}
local tbl = {}
for i=1,3 do
local pick = table.Random(fulltable)
table.insert(tbl, pick)
end
net.Start("example")
net.WriteTable(tbl)
net.Broadcast()
[/code]
But when I read the table clientside, the value is read fine but the key isn't sent, so it's 1,2,3,4,5, etc and while this isn't the end of the world - I would like to get this working so a solution to my issue would be greatly appreciated, ty![/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/KeyFromValue]table.KeyFromValue[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/KeysFromValue]table.KeysFromValue[/url]
Those functions use [url=http://wiki.garrysmod.com/page/Global/pairs]pairs[/url], as does table.Random (twice). That's a lot of looping, so you might want to switch to sequential keys and use math.random, if possible for whatever you're doing.
[QUOTE=P4sca1;49117637]Hey, I want a function to be executed, every server start/map change and from there every 10800 seconds. Here is what I got so far (the function is working, but not executed every server start/map change):
[CODE]
local function ConnectAPI()
http.Fetch( "https://bitcoinapi.de/v1/NOPE/rate.json",
function( body, len, headers, code )
if body == "api call limit reached" then
MsgC( Color( 255, 0, 0 ), "[BM DEBUG] ERROR: api call limit reached\n" )
else
local value = util.JSONToTable( body )
bitconfig.bitvalue = math.Round( tonumber( value["rate_weighted_3h"] ), 0 )
MsgC( Color( 33, 150, 243 ), "[BM DEBUG]", Color( 255, 255, 255), "Der aktuelle Wert beträgt ", Color( 33, 150, 243 ), bitconfig.bitvalue, Color( 255, 255, 255 ), "€ pro BitCoin\n" )
end
end,
function( error )
MsgC( Color( 255, 0, 0 ), "[BM DEBUG] ERROR: Verbindung mit API konnte nicht hergestellt werden\n" )
end
)
end
timer.Create( "BitMinerConnectAPI", 10800, 0, ConnectAPI )
hook.Add("Initialize", function()
ConnectAPI()
end)
[/CODE]
[/QUOTE]
are... are you making a bitcoin mining simulator?
[QUOTE=Skere_;49115619]Oh right forgot about them, will use that.
EDIT: It worked fine, thanks.
Just for educational purposes, mind explaining why my old code didn't work?[/QUOTE]
That code you showed looked like it would've worked perfectly. I assume you were doing that in a playerdeath hook, chances are you got a few "if" statements mixed up before you wrote that. Can you post the whole playerdeath func you used before? The other possibility is that you were trying to access it clientside when you were defining the variable serverside or something like that(team.SetScore is networked iirc, while your global variables weren't)
[editline]15th November 2015[/editline]
say, anyone got a picture of using a dscrollpanel? the gmod wiki has no pictures and I'm looking to add one to my custom scoreboard
[QUOTE=MaximLaHaxim;49118795]That code you showed looked like it would've worked perfectly. I assume you were doing that in a playerdeath hook, chances are you got a few "if" statements mixed up before you wrote that. Can you post the whole playerdeath func you used before? The other possibility is that you were trying to access it clientside when you were defining the variable serverside or something like that(team.SetScore is networked iirc, while your global variables weren't)
[editline]15th November 2015[/editline]
say, anyone got a picture of using a dscrollpanel? the gmod wiki has no pictures and I'm looking to add one to my custom scoreboard[/QUOTE]
[t]http://images.akamai.steamusercontent.com/ugc/393298345486011371/E26AE375FA9D125197CD274FB59AA356BC387D9F/[/t]
[t]http://images.akamai.steamusercontent.com/ugc/393298345486003905/2D21950870356F5FEE574B0BDDE1723D756B1B77/[/t]
It's used like the DFrame/DPanel is.
[QUOTE=AwfulRanger;49118909][t]http://images.akamai.steamusercontent.com/ugc/393298345486011371/E26AE375FA9D125197CD274FB59AA356BC387D9F/[/t]
[t]http://images.akamai.steamusercontent.com/ugc/393298345486003905/2D21950870356F5FEE574B0BDDE1723D756B1B77/[/t]
It's used like the DFrame/DPanel is.[/QUOTE]
what was the code you used? this code I'm using isn't working
[code]function CL_CreateScoreBoard()
local p_Board = vgui.Create( "DFrame" )
p_Board:SetTitle( "Scoreboard" )
p_Board:SetSize( 800, 580 )
p_Board:Center()
local p_DScrollPan = vgui.Create( "DScrollPanel", p_Board )
p_DScrollPan:Dock( FILL )
for _, ent in pairs(GAMEMODE.CL_RebelsTab) do
local p_DPanel = vgui.Create( "DPanel", p_DScrollPan )
p_DPanel:DockMargin( 30, 80, 60, 400 ) -- left, top, right, bottom
p_DPanel:Dock( RIGHT )
function p_DPanel:Think()
if !IsValid(ent) then
p_DPanel:Remove()
end
end
local oldPaint = p_DPanel.Paint
function p_DPanel:Paint( w, h )
oldPaint( p_DPanel, w, h )
DisableClipping( true )
draw.SimpleText( "Rebel "..ent:EntIndex(), "TargetID", w - 65, h - 100, Color( 255, 255, 255, 255 ) )
DisableClipping( false )
end
local p_DModel = vgui.Create( "DModelPanel", p_DPanel )
p_DModel:DockMargin( 5, 5, 5, 5 )
p_DModel:Dock( FILL )
p_DModel:SetModel( ent:GetModel() )
function p_DModel:LayoutEntity( ent ) return end
local headpos = p_DModel.Entity:GetBonePosition( p_DModel.Entity:LookupBone( "ValveBiped.Bip01_Head1" ) )
p_DModel:SetLookAt( headpos )
p_DModel:SetCamPos( headpos-Vector( -15, 0, 0 ) )
p_DModel.Entity:SetEyeTarget( headpos-Vector( -15, 0, 0 ) )
end
--for ply=1, 5 do -- only draw the first 5 players in player.getall(the max we can fit on the scoreboard)
p_Board:MakePopup()
p_Board:DoModal()
return p_Board
end[/code]
I have to have gotten something fucked up, what did I do?
[QUOTE=MaximLaHaxim;49118922]what was the code you used? this code I'm using isn't working
[code]function CL_CreateScoreBoard()
local p_Board = vgui.Create( "DFrame" )
p_Board:SetTitle( "Scoreboard" )
p_Board:SetSize( 800, 580 )
p_Board:Center()
local p_DScrollPan = vgui.Create( "DScrollPanel", p_Board )
p_DScrollPan:Dock( FILL )
for _, ent in pairs(GAMEMODE.CL_RebelsTab) do
local p_DPanel = vgui.Create( "DPanel", p_DScrollPan )
p_DPanel:DockMargin( 30, 80, 60, 400 ) -- left, top, right, bottom
p_DPanel:Dock( RIGHT )
function p_DPanel:Think()
if !IsValid(ent) then
p_DPanel:Remove()
end
end
local oldPaint = p_DPanel.Paint
function p_DPanel:Paint( w, h )
oldPaint( p_DPanel, w, h )
DisableClipping( true )
draw.SimpleText( "Rebel "..ent:EntIndex(), "TargetID", w - 65, h - 100, Color( 255, 255, 255, 255 ) )
DisableClipping( false )
end
local p_DModel = vgui.Create( "DModelPanel", p_DPanel )
p_DModel:DockMargin( 5, 5, 5, 5 )
p_DModel:Dock( FILL )
p_DModel:SetModel( ent:GetModel() )
function p_DModel:LayoutEntity( ent ) return end
local headpos = p_DModel.Entity:GetBonePosition( p_DModel.Entity:LookupBone( "ValveBiped.Bip01_Head1" ) )
p_DModel:SetLookAt( headpos )
p_DModel:SetCamPos( headpos-Vector( -15, 0, 0 ) )
p_DModel.Entity:SetEyeTarget( headpos-Vector( -15, 0, 0 ) )
end
--for ply=1, 5 do -- only draw the first 5 players in player.getall(the max we can fit on the scoreboard)
p_Board:MakePopup()
p_Board:DoModal()
return p_Board
end[/code]
I have to have gotten something fucked up, what did I do?[/QUOTE]
[lua]concommand.Add( "dscrollmenu", function()
local Menu = vgui.Create( "DFrame" )
Menu:SetPos( ScrW() * 0.1, ScrH() * 0.1 )
Menu:SetSize( ScrW() * 0.8, ScrH() * 0.8 )
Menu:MakePopup()
local MenuScroll = vgui.Create( "DScrollPanel" )
MenuScroll:SetParent( Menu )
MenuScroll:Dock( FILL )
for i = 0, 39 do
local Buttons = vgui.Create( "DButton" )
Buttons:SetParent( MenuScroll )
Buttons:SetPos( 0, ScrH() * 0.1 * i )
Buttons:SetSize( Menu:GetWide(), ScrH() * 0.1 )
end
end )[/lua]
This is something I've been wondering for a while now- is it possible within Lua to generate a number/string/whatever that couldn't ever possibly be generated the same again at any point of time?
I thought about using os.date or something like that but since different users may have different time zones, there could be an overlap if two users try to generate it at the same time.
[QUOTE=MPan1;49119553]This is something I've been wondering for a while now- is it possible within Lua to generate a number/string/whatever that couldn't ever possibly be generated the same again at any point of time?
I thought about using os.date or something like that but since different users may have different time zones, there could be an overlap if two users try to generate it at the same time.[/QUOTE]
os.date times their unique player id?
[QUOTE=MPan1;49119553]This is something I've been wondering for a while now- is it possible within Lua to generate a number/string/whatever that couldn't ever possibly be generated the same again at any point of time?
I thought about using os.date or something like that but since different users may have different time zones, there could be an overlap if two users try to generate it at the same time.[/QUOTE]
uhhhh all digits within their steamid greater than 0 multiplied/added together?
dunno if that has any possible conflicts.
[QUOTE=Z0mb1n3;49119906]uhhhh all digits within their steamid greater than 0 multiplied/added together?
dunno if that has any possible conflicts.[/QUOTE]
needs to be different each time it's called by the same player, that could work if multipled by the system time, although there is a possibility of two players having the same result still
[QUOTE=Splerge;49119966]needs to be different each time it's called by the same player, that could work if multipled by the system time, although there is a possibility of two players having the same result still[/QUOTE]
oh, for some reason I thought he said a unique number for each player, silly me.
I'm not sure this would be very efficient, but you could make a mysql table that stores each generated number, and then make a custom function that generates a number sequence and continually regenerates it until it creates a sequence not in the table, then stores it in the table.
[QUOTE=zerf;49118245]are... are you making a bitcoin mining simulator?[/QUOTE]
[url]https://scriptfodder.com/scripts/view/1363[/url]
I just heavily modified this addon. I'm using the real bitcoin value, which I get from their API for example.
I fixed my problem with the BitMinerAPI Code. The problem was, that the variable, containing the bitvalue got overritten, after the Initialize hook.
Any idea, why my other code won't work?
[CODE]
local function SetOwner(ply, ent)
ent:SetNWEntity("owner", ply)
end
hook.Add("PlayerSpawnedSENT", "SetCPPIOwnerSENT", SetOwner)
local function RemoveOwnEntities( ply, tr, tool )
if tool == "remover" and IsValid( tr.Entity ) and tr.Entity:GetNWEntity("owner") == ply then
return true
end
end
hook.Add( "CanTool", "AllowRemovingOwnEntities", RemoveOwnEntities )
[/CODE]
I'm trying to allow everyone to remove their own entities spawned in DarkRP via F4.
[QUOTE=P4sca1;49120542][url]https://scriptfodder.com/scripts/view/1363[/url]
I just heavily modified this addon. I'm using the real bitcoin value, which I get from their API for example.
I fixed my problem with the BitMinerAPI Code. The problem was, that the variable, containing the bitvalue got overritten, after the Initialize hook.
Any idea, why my other code won't work?
[CODE]
local function SetOwner(ply, ent)
ent:SetNWEntity("owner", ply)
end
hook.Add("PlayerSpawnedSENT", "SetCPPIOwnerSENT", SetOwner)
local function RemoveOwnEntities( ply, tr, tool )
if tool == "remover" and IsValid( tr.Entity ) and tr.Entity:GetNWEntity("owner") == ply then
return true
end
end
hook.Add( "CanTool", "AllowRemovingOwnEntities", RemoveOwnEntities )
[/CODE]
I'm trying to allow everyone to remove their own entities spawned in DarkRP via F4.[/QUOTE]
[url]http://wiki.darkrp.com/index.php/Hooks/Server/playerBoughtCustomEntity[/url]
Also, use CPPISetOwner instead of SetNWEntity
On the other hook, just call CPPIGetOwner in the same way.
(Screw it, I'll just use a DVScrollBar for the job, here's the code now:[code]function CL_CreateScoreBoard()
local p_Board = vgui.Create( "DFrame" )
p_Board:SetTitle( "Scoreboard" )
p_Board:SetSize( 800, 580 )
p_Board:Center()
local p_VertScroll = vgui.Create( "DVScrollBar", p_Board )
p_VertScroll:Dock( LEFT )
p_VertScroll:InvalidateParent( true )
p_VertScroll:SetUp( p_VertScroll:GetTall() - 16, p_Board:GetTall() )
for _, ent in pairs(GAMEMODE.CL_RebelsTab) do
local p_DPanel = vgui.Create( "DPanel", p_Board )
p_DPanel:DockMargin( 30, 80, 60, 400 ) -- left, top, right, bottom
p_DPanel:Dock( RIGHT )
function p_DPanel:Think()
if !IsValid(ent) then
p_DPanel:Remove()
end
end
local oldPaint = p_DPanel.Paint
function p_DPanel:Paint( w, h )
oldPaint( p_DPanel, w, h )
DisableClipping( true )
draw.SimpleText( "Rebel "..ent:EntIndex(), "TargetID", w - 65, h - 100, Color( 255, 255, 255, 255 ) )
DisableClipping( false )
end
local p_DModel = vgui.Create( "DModelPanel", p_DPanel )
p_DModel:DockMargin( 5, 5, 5, 5 )
p_DModel:Dock( FILL )
p_DModel:SetModel( ent:GetModel() )
function p_DModel:LayoutEntity( ent ) return end
local headpos = p_DModel.Entity:GetBonePosition( p_DModel.Entity:LookupBone( "ValveBiped.Bip01_Head1" ) )
p_DModel:SetLookAt( headpos )
p_DModel:SetCamPos( headpos-Vector( -15, 0, 0 ) )
p_DModel.Entity:SetEyeTarget( headpos-Vector( -15, 0, 0 ) )
end
p_Board:MakePopup()
p_Board:DoModal()
return p_Board
end[/code])
But, now I have another problem....
[img]http://i.imgur.com/bgZgvkr.jpg[/img]
The scroll bar doesn't fill the entirety of the entire size of the bar itself... I'm 100% sure it has to do with this line...
[code]p_VertScroll:SetUp( p_VertScroll:GetTall() - 16, p_Board:GetTall() )[/code]
What do I need to use to get this to function correctly?
[QUOTE=MaximLaHaxim;49121002]
What do I need to use to get this to function correctly?[/QUOTE]
Maybe you can play around with the '- 16' around and see if it had anything to do with it.
[QUOTE=mib999;49120656][url]http://wiki.darkrp.com/index.php/Hooks/Server/playerBoughtCustomEntity[/url]
Also, use CPPISetOwner instead of SetNWEntity
On the other hook, just call CPPIGetOwner in the same way.[/QUOTE]
It is working fine now.
I only have one problem left, with this piece of code:
[CODE]
--restrict freezing of some entities
local cantFreeze = {
["adrug_weed_plant"] = true,
--add more here!
}
local function RestrictFreeze(weapon, phys, ent, ply)
if cantFreeze[ent:GetClass()] then
return false
end
end
hook.Add("OnPhysGunFreeze", "RestrictFreeze", RestrictFreeze)
[/CODE]
It should prevent players from freezing the entity with the class "adrug_weed_plant" but they still can freeze it.
The hook is OnPhysgunFreeze and not OnPhysGunFreeze
[QUOTE=mib999;49122707]The hook is OnPhysgunFreeze and not OnPhysGunFreeze[/QUOTE]
I tried everything, but it never came to my mind that I may have misspelled the hook name. Thanks in advance!
Okay, I got the DVScrollBar to work fine, but I've ran into a problem.
[code]function CL_CreateScoreBoard()
local p_Board = vgui.Create( "DFrame" )
p_Board:SetTitle( "Scoreboard" )
p_Board:SetSize( 800, 580 )
p_Board:Center()
local p_VertScroll = vgui.Create( "DVScrollBar", p_Board )
p_VertScroll:Dock( LEFT )
p_VertScroll:InvalidateParent( true )
p_VertScroll:SetUp( p_VertScroll:GetTall() + 34, p_Board:GetTall() )
for _, ent in pairs(GAMEMODE.CL_RebelsTab) do
local p_DPanel = vgui.Create( "DPanel", p_Board )
p_DPanel:DockMargin( 30, 80, 60, 400 ) -- left, top, right, bottom
p_DPanel:Dock( RIGHT )
function p_DPanel:Think()
if !IsValid(ent) then
p_DPanel:Remove()
end
end
local oldPaint = p_DPanel.Paint
function p_DPanel:Paint( w, h )
oldPaint( p_DPanel, w, h )
DisableClipping( true )
draw.SimpleText( "Rebel "..ent:EntIndex(), "TargetID", w - 65, h - 100, Color( 255, 255, 255, 255 ) )
DisableClipping( false )
end
local p_DModel = vgui.Create( "DModelPanel", p_DPanel )
p_DModel:DockMargin( 5, 5, 5, 5 )
p_DModel:Dock( FILL )
p_DModel:SetModel( ent:GetModel() )
function p_DModel:LayoutEntity( ent ) p_DModel:RunAnimation() end
local headpos = p_DModel.Entity:GetBonePosition( p_DModel.Entity:LookupBone( "ValveBiped.Bip01_Head1" ) )
p_DModel:SetLookAt( headpos )
p_DModel:SetCamPos( headpos-Vector( -15, 0, 0 ) )
p_DModel.Entity:SetEyeTarget( headpos-Vector( -15, 0, 0 ) )
end
for i=1, #player.GetAll() do
local p_DPPanel = vgui.Create( "DPanel", p_Board )
p_DPPanel:DockMargin( 30, 400, 60, 80 ) -- left, top, right, bottom
p_DPPanel:Dock( RIGHT )
p_DPPanel:CenterVertical( 0.5 )
function p_DPPanel:Think()
if !player.GetAll()[i]:Alive() then
p_DPPanel:Remove()
end
end
local oldPaint = p_DPPanel.Paint
function p_DPPanel:Paint( w, h )
oldPaint( p_DPPanel, w, h )
DisableClipping( true )
draw.SimpleText( player.GetAll()[i]:Nick(), "TargetID", w - 65, h - 100, Color( 255, 255, 255, 255 ) )
DisableClipping( false )
end
local p_DPModel = vgui.Create( "DModelPanel", p_DPPanel )
p_DPModel:DockMargin( 5, 5, 5, 5 )
p_DPModel:Dock( FILL )
p_DPModel:SetModel( player.GetAll()[i]:GetModel() )
function p_DPModel:LayoutEntity( ent ) p_DPModel:RunAnimation() end
local headpos = p_DPModel.Entity:GetBonePosition( p_DPModel.Entity:LookupBone( "ValveBiped.Bip01_Head1" ) )
p_DPModel:SetLookAt( headpos )
p_DPModel:SetCamPos( headpos-Vector( -15, 0, 0 ) )
p_DPModel.Entity:SetEyeTarget( headpos-Vector( -15, 0, 0 ) )
end
p_Board:MakePopup()
p_Board:DoModal()
return p_Board
end[/code]
Due to docking, once the rebels panels show up, my player panel disappears off of the DFrame completely. What do I need to do to get the player panels to stay on the DFrame instead of getting "pushed off" once the rebel panels come?
I'm using this snippet of code in a file in lua/autorun/server:
[CODE]hook.Add( "PlayerSay", "getchat", GetChat )
local function GetChat( ply, text, public )
print("I heard ya!")
//whenever chat is used
//look for a flower to give the text to!
for k, v in pairs( ents.FindByClass("echo_flower") ) do
print("Flower Found!")
if v:GetClass() == "echo_flower" then
//but make sure the player is close enough!
FlowerLoc = v:GetPos()
PlayerLoc = ply:GetPos()
if (FlowerLoc:Distance( PlayerLoc ) < 325) then
v.LastHeard = text
return text
end
end
end
end[/CODE]
In this case, saying something in chat should print "I heard ya!" in console, but it doesn't.
An oddity I've come across with it: if I put it in just "lua/autorun", then it will completely work in Singleplayer, but nothing will happen in online multiplayer servers.
Am I doing something wrong with the hook or with the file setup?
[QUOTE=Becomeimp;49124014]I'm using this snippet of code in a file in lua/autorun/server:
[CODE]hook.Add( "PlayerSay", "getchat", GetChat )
local function GetChat( ply, text, public )
print("I heard ya!")
//whenever chat is used
//look for a flower to give the text to!
for k, v in pairs( ents.FindByClass("echo_flower") ) do
print("Flower Found!")
if v:GetClass() == "echo_flower" then
//but make sure the player is close enough!
FlowerLoc = v:GetPos()
PlayerLoc = ply:GetPos()
if (FlowerLoc:Distance( PlayerLoc ) < 325) then
v.LastHeard = text
return text
end
end
end
end[/CODE]
In this case, saying something in chat should print "I heard ya!" in console, but it doesn't.
An oddity I've come across with it: if I put it in just "lua/autorun", then it will completely work in Singleplayer, but nothing will happen in online multiplayer servers.
Am I doing something wrong with the hook or with the file setup?[/QUOTE]
it is working, using print() serverside will not make anything print to your console on your client. Checking the server's console.log if it has one ( -condebug as a startup parameter) should have your prints in it.
When you're in single player the serverside prints show up in your client console, they will be coloured blue.
Well, I wanna know a method to use [URL="http://wiki.garrysmod.com/page/Global/CreateMaterial"]CreateMaterial[/URL] in [URL="http://wiki.garrysmod.com/page/Entity/SetSubMaterial"]SetSubMaterial[/URL] when I use DirectX 8 or 8.5. VertexLitGeneric_DX8 and VertexLitGeneric shaders won't work.
I know only one metod(use special vmt file), but I can create only one [URL="http://wiki.garrysmod.com/page/Global/Material"]Material[/URL] with same name.
Please, someone, help me:(. I search help for 4 months, but don't find. Robotboy, if you read this, please, help :(.
I am making a HUD and it has been doing well (Other than the chat T_T) and I was starting on my scoreboard and while making it this error occurred and I am not sure why I don't see anything wrong with it, here is the first table in which the error is occurring. It is probably something simple I overlooked.
[ERROR] addons/xenoth_hud/lua/autorun/scoreboard.lua:4: unexpected symbol near 'local'
1. unknown - addons/xenoth_hud/lua/autorun/scoreboard.lua:0
[code]
local Scoreboard = {
//ScreenScale
local SCREEN_W, SCREEN_H = 1280, 768;
local _w, _h = ScrW( ), ScrH( );
local _wMod, _hMod = _w / SCREEN_W, _h / SCREEN_H
local d_scoreboard = vgui.Create("DFrame")
d_scoreboard:SetPos(_wMod*150, _hMod*100)
d_scoreboard:SetSize( _wMod*980, _hMod*568)
d_scoreboard:SetTitle("Scoreboard")
d_scoreboard:SetVisible(true)
d_scoreboard:SetDraggable(false)
d_scoreboard:ShowCloseButton(false)
d_scoreboard:MakePopup()
d_scoreboard.Paint = function()
draw.RoundedBox(3, 0, 0, d_scoreboard:GetWide(), d_scoreboard:GetTall(), Color(36,36,36,225))
end
local PropertySheet = vgui.Create("DPropertySheet")
PropertySheet:SetParent(d_scoreboard)
PropertySheet:SetPos(_wMod*5, _hMod*30)
PropertySheet:SetSize()
}
[/code]
[QUOTE=Tatsumi-Chan;49130246]
[ERROR] addons/xenoth_hud/lua/autorun/scoreboard.lua:4: unexpected symbol near 'local'
1. unknown - addons/xenoth_hud/lua/autorun/scoreboard.lua:0
[/QUOTE]
Maybe it's the
[CODE];[/CODE]?
Edit: Didn't even notice that was a table
-im a dumb fuck at 2am. Sorry-
[QUOTE=Tatsumi-Chan;49130246]I am making a HUD and it has been doing well (Other than the chat T_T) and I was starting on my scoreboard and while making it this error occurred and I am not sure why I don't see anything wrong with it, here is the first table in which the error is occurring. It is probably something simple I overlooked.
[ERROR] addons/xenoth_hud/lua/autorun/scoreboard.lua:4: unexpected symbol near 'local'
1. unknown - addons/xenoth_hud/lua/autorun/scoreboard.lua:0
[code]
local Scoreboard = {
//ScreenScale
local SCREEN_W, SCREEN_H = 1280, 768;
local _w, _h = ScrW( ), ScrH( );
local _wMod, _hMod = _w / SCREEN_W, _h / SCREEN_H
local d_scoreboard = vgui.Create("DFrame")
d_scoreboard:SetPos(_wMod*150, _hMod*100)
d_scoreboard:SetSize( _wMod*980, _hMod*568)
d_scoreboard:SetTitle("Scoreboard")
d_scoreboard:SetVisible(true)
d_scoreboard:SetDraggable(false)
d_scoreboard:ShowCloseButton(false)
d_scoreboard:MakePopup()
d_scoreboard.Paint = function()
draw.RoundedBox(3, 0, 0, d_scoreboard:GetWide(), d_scoreboard:GetTall(), Color(36,36,36,225))
end
local PropertySheet = vgui.Create("DPropertySheet")
PropertySheet:SetParent(d_scoreboard)
PropertySheet:SetPos(_wMod*5, _hMod*30)
PropertySheet:SetSize()
}
[/code][/QUOTE]
You can't define variables inside of a table, or perform functions inside of them like you're doing.
Do you know what tables are for?
[QUOTE=geferon;49131500]It is.
Dount use semicolons inside a table[/QUOTE]
That is far from the only thing wrong with his code. Plus, you can use semicolons in tables.
You can't just put table brackets around your code and expect it to work. You're defining local variables and what not inside your table.
I didn't even notice that was a table
[QUOTE=ms333;49131560]That is far from the only thing wrong with his code. Plus, you can use semicolons in tables.
You can't just put table brackets around your code and expect it to work. You're defining local variables and what not inside your table.[/QUOTE]
It was 2 am.
I wasnt aware of what i was seeing.
I made 2 dumb posts in 1 minute, just beacouse i was sleepy.
Sorry
Sorry, you need to Log In to post a reply to this thread.