I am creating a taunt script and basically what is shown in the code below is the script grabbing values from tables located in the config file. Now the problem is that the code grabbing the taunt path and points is being ran twice. I am sure this is caused by the "for path, points in pairs" being inside of "for v, k in pairs" but im not sure how to fix it. Any help is appreciated.
[lua]
for v, k in pairs ( tm.taunts ) do
if layout:Valid() then
local tauntButton = layout:Add( "DButton", body )
tauntButton:SetSize( body:GetWide(), 50 )
tauntButton:SetPos( 0, ( ( 30 * v ) - 30 ) )
tauntButton:SetText( "" )
tauntButton.DoClick = function()
tm_canOpenMenu = 0;
panel:SetVisible( false )
blur:SetVisible( false )
timer.Simple( tm.spamTime, function()
tm_canOpenMenu = 1;
end )
print("test")
for path, points in pairs(tm.paths) do --[START] Code ran twice
//Send taunt path to server
net.Start("send_taunt")
net.WriteString( path )
net.SendToServer()
//Send points
net.Start( "send_points" )
print("Points:"..points) --I used this to test how many times it was ran
net.WriteInt( points, points+10 )
net.SendToServer()
end --[END] Code ran twice
end
function tauntButton:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 30, 30, 30, 200 ) )
end
local tauntText = vgui.Create( "DLabel", tauntButton )
tauntText:SetPos( 7, 12 )
tauntText:SetPos( body:GetWide() / 2.5, 12 )
tauntText:SetText( table.concat( tm.taunts, "", v, v ) )
tauntText:SetFont( "TauntName" )
tauntText:SizeToContents()
end
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.