Hi guys
I tried to install the ttt specialrounds plugin for ttt from coderhire (free addon) but
i got this error:
[ERROR] lua/hud.lua:10: attempt to index global 'surface' (a nil value)
1. unknown - lua/hud.lua:10
2. include - [C]:-1
3. unknown - lua/autorun/cl_init.lua:4
Here is the code of the hud.lua
[code]
/*hook.Add( "Think", "SR_Think", function()
if !GetGlobalBool( "SpecialVote_IP" ) then return end
if input.IsKeyDown( KEY_0 ) then
RunConsoleCommand( "sr_vote", 1 ); print( "test" )
elseif input.IsKeyDown( KEY_9 ) then
RunConsoleCommand( "sr_vote", 2 ); print( "test2" )
end
end )*/
local inno = surface.GetTextureID( "VGUI/ttt/icon_inno" )
local traitor = surface.GetTextureID( "VGUI/ttt/icon_traitor" )
local det = surface.GetTextureID( "VGUI/ttt/icon_det" )
local endtime = 0
usermessage.Hook( "SpecialVote", function( um )
endtime = CurTime() + SR_VOTETIME
end )
local mode = -1
usermessage.Hook( "SpecialHUD", function( um )
mode = um:ReadLong()
if SR_DEBUG then print( "Mode: " .. tostring( mode ) ) end
end )
local function SpecialHUD()
// Voting Portion of HUD
if ( GetGlobalBool( "SpecialVote_IP" ) and endtime > CurTime() ) or SR_DEBUG then
local w, h = 130, 128
local x, y = ( ScrW() - w + 6 ), ( ScrH()/2 - h/2 )
local margin = 15
draw.RoundedBox( 6, x, y, w, h, Color( 0, 0, 0, 175 ) )
draw.SimpleText( "Special Round Vote:", "Trebuchet18", x + 6, y + 3, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM ); y = y + margin + 4
surface.SetDrawColor( 255, 255, 255, 255 ); surface.DrawLine( x + 6, y + 4, x + w - 10, y + 4 );
draw.SimpleText( "1. FFA", "Trebuchet18", x + 6, y + 4, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM ); y = y + margin
draw.SimpleText( "2. TvD", "Trebuchet18", x + 6, y + 4, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM ); y = y + margin + 4
surface.SetDrawColor( 255, 255, 255, 255 ); surface.DrawLine( x + 6, y + 4, x + w - 10, y + 4 );
draw.SimpleText( "Select by typing:", "Trebuchet18", x + 6, y + 4, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM ); y = y + margin - 2
draw.SimpleText( "!srvote #", "Trebuchet18", x + 6, y + 4, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM ); y = y + margin + 4
surface.SetDrawColor( 255, 255, 255, 255 ); surface.DrawLine( x + 6, y + 4, x + w - 10, y + 4 );
draw.SimpleText( "Time Left:" .. tostring( math.ceil( endtime - CurTime() ) ), "Trebuchet18", x + 6, y + 4, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM ); y = y + margin + 4
surface.SetDrawColor( 255, 255, 255, 255 ); surface.DrawLine( x + 6, y + 4, x + w - 10, y + 4 );
draw.SimpleText( "FFA: " .. tostring( GetGlobalInt( "SR_Vote_1" ) ) .. " | TvD: " .. tostring( GetGlobalInt( "SR_Vote_2" ) ), "Trebuchet18", x + 6, y + 4, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM )
end
// Main HUD
if SR_HUD and ( mode != -1 or SR_DEBUG ) then
draw.SimpleText( "Special Round", "SR_Title", ScrW()/2, 120, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
surface.SetDrawColor( 255, 255, 255, 255 )
local time = math.ceil( ( endtime + SR_VOTE_NOTICETIME ) - CurTime() )
if mode == 0 then // Preparing
draw.SimpleText( "In Vote (" .. tostring( math.ceil( endtime - CurTime() ) ) .. ")", "SR_Subtitle", ScrW()/2, 195, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
// --------------------------- //
surface.SetTexture( inno )
surface.DrawTexturedRect( ScrW()/2 - 220, 225, 60, 60 )
draw.SimpleText( "vs.", "SR_Subtitle", ScrW()/2 - 120, 255, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
draw.SimpleText( tostring( GetGlobalInt( "SR_Vote_1", 0 ) ), "SR_Sub_subtitle", ScrW()/2 - 120, 305, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
surface.DrawTexturedRect( ScrW()/2 - 75, 225, 60, 60 )
// ------------------------------ //
surface.SetTexture( traitor )
surface.DrawTexturedRect( ScrW()/2 + 75, 225, 60, 60 )
draw.SimpleText( "vs.", "SR_Subtitle", ScrW()/2 + 180, 255, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
draw.SimpleText( tostring( GetGlobalInt( "SR_Vote_2", 0 ) ), "SR_Sub_subtitle", ScrW()/2 + 180, 305, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
surface.SetTexture( det )
surface.DrawTexturedRect( ScrW()/2 + 220, 225, 60, 60 )
elseif mode == 1 then // FFA
surface.SetTexture( inno )
surface.DrawTexturedRect( ScrW()/2 - 175, 165, 60, 60 )
draw.SimpleText( "vs.", "SR_Subtitle", ScrW()/2, 195, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
draw.SimpleText( "Free For All", "SR_Sub_subtitle", ScrW()/2, 245, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
surface.DrawTexturedRect( ScrW()/2 + 115, 165, 60, 60 )
if SR_VOTE_NOTICETIME > 0 and time >= 0 then
draw.SimpleText( "Round Starts in: " .. tostring( math.abs( time ) ) .. " seconds", "SR_Sub_subtitle", ScrW()/2, 305, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
end
elseif mode == 2 then // TVD
surface.SetTexture( traitor )
surface.DrawTexturedRect( ScrW()/2 - 175, 165, 60, 60 )
draw.SimpleText( "vs.", "SR_Subtitle", ScrW()/2, 195, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
draw.SimpleText( "Traitors vs. Detectives", "SR_Sub_subtitle", ScrW()/2, 245, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
surface.SetTexture( det )
surface.DrawTexturedRect( ScrW()/2 + 115, 165, 60, 60 )
if SR_VOTE_NOTICETIME > 0 and time >= 0 then
draw.SimpleText( "Round Starts in: " .. tostring( time ) .. " seconds", "SR_Sub_subtitle", ScrW()/2, 305, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
end
end
end
end
hook.Add( "HUDPaint", "SpecialVote_HUD", SpecialHUD )
surface.CreateFont( "SR_Title", { font = "Trebuchet MS", size = 100, weight = 900, outline = true } )
surface.CreateFont( "SR_Subtitle", { font = "Trebuchet MS", size = 60, weight = 600, outline = true } )
surface.CreateFont( "SR_Sub_subtitle", { font = "Trebuchet MS", size = 45, weight = 400, outline = true } )
[/code]
need help
[editline]29th November 2013[/editline]
nobody can help my?
It doesn't work anyways, read the thread.
Where did you put the file? This error usually happens when you try to include a clientside file on the server, since the surface library is only available to the client.
[QUOTE=code_gs;43023678]Where did you put the file? This error usually happens when you try to include a clientside file on the server, since the surface library is only available to the client.[/QUOTE]
[url]http://www.mediafire.com/?6r95us84gfua1du[/url] <- addon :P
[editline]30th November 2013[/editline]
pls...
Sorry, you need to Log In to post a reply to this thread.