I made a logo on hud script and it works if i execute it client side, but i made it an addon and it isn't working. It's just a lua folder then autorun then logo_client.lua in there and logo.png in it. I don't know what's wrong.
[code] local x = ScrW()
local y = ScrH()
local width = 225 -- Change this Based on the width dimension for your logo.
local height = 160 -- Change this Based on the height dimension of your logo.
local DonationLink = http://birdrp.gaming.bz/prometheus/ -- Change this Based on the server's Donation Link.
local Logo = vgui.Create("DImage")
Logo:SetPos( x / 50, y / 50 )
Logo:SetSize( width, height )
Logo:SetImage( "logo.png" )
file.Find( "lua/autorun/logo.png", "BACKGROUND" )
local Button1 = vgui.Create("DButton")
Button1:SetSize( width, height )
Button1:SetPos(x / 50, y / 50)
Button1:SetText("")
Button1.Paint = function(me,w,h)
surface.SetDrawColor(Color(0,0,0,0))
surface.DrawRect(0,0,w,h)
end
Button1.DoClick = function()
gui.OpenURL( DonationLink )
end [/code]
you need to place the .lua file in lua/autorun/[B]client[/B]
or place
[CODE] if CLIENT then [/CODE] on the beginning
and [CODE] end [/CODE] at the end
[QUOTE=AlbertoBC;51142796]you need to place the .lua file in lua/autorun/[B]client[/B]
or place
[CODE] if CLIENT then [/CODE] on the beginning
and [CODE] end [/CODE] at the end[/QUOTE]
i did that and im getting this error
[code] Warning: vgui.Create failed to create the VGUI component (DImage)
[ERROR] addons/logoonhud/lua/autorun/logo_client.lua:7: attempt to index local 'Logo' (a nil value)
1. unknown - addons/logoonhud/lua/autorun/logo_client.lua:7
[/code]
This part: [lua]local DonationLink = [url]http://birdrp.gaming.bz/prometheus/[/url] -- Change this Based on the server's Donation Link[/lua] should be a string,
[lua]file.Find( "lua/autorun/logo.png", "BACKGROUND" )[/lua] wat.
Should be like this:
[lua]
local logo = false
local button = false
local x = ScrW()
local y = ScrH()
local width,height = 225,160
function MakeThem()
if !logo then
local Logo = vgui.Create("DImage")
Logo:SetPos( x / 50, y / 50 )
Logo:SetSize( width, height )
Logo:SetImage( "logo.png" )
logo = true
end
if !button then
local Button1 = vgui.Create("DButton")
Button1:SetSize( width, height )
Button1:SetPos(x / 50, y / 50)
Button1:SetText("")
Button1.Paint = function(me,w,h)
surface.SetDrawColor(Color(0,0,0,0))
surface.DrawRect(0,0,w,h)
end
Button1.DoClick = function()
gui.OpenURL( DonationLink )
end
button = true
end
end
MakeThem()
[/lua]
[QUOTE=Its Pawsative;51142958]This part: [lua]local DonationLink = [url]http://birdrp.gaming.bz/prometheus/[/url] -- Change this Based on the server's Donation Link[/lua] should be a string,
[lua]file.Find( "lua/autorun/logo.png", "BACKGROUND" )[/lua] wat.
Should be like this:
[lua]
local logo = false
local button = false
local x = ScrW()
local y = ScrH()
local width,height = 225,160
function MakeThem()
if !logo then
local Logo = vgui.Create("DImage")
Logo:SetPos( x / 50, y / 50 )
Logo:SetSize( width, height )
Logo:SetImage( "logo.png" )
logo = true
end
if !button then
local Button1 = vgui.Create("DButton")
Button1:SetSize( width, height )
Button1:SetPos(x / 50, y / 50)
Button1:SetText("")
Button1.Paint = function(me,w,h)
surface.SetDrawColor(Color(0,0,0,0))
surface.DrawRect(0,0,w,h)
end
Button1.DoClick = function()
gui.OpenURL( DonationLink )
end
button = true
end
end
MakeThem()
[/lua][/QUOTE]
that doesn't work
[QUOTE=peatreat;51143088]that doesn't work[/QUOTE]
it just didnt work or are there errors?
[QUOTE=Fresh~;51143186]it just didnt work or are there errors?[/QUOTE]
did it and got this error
[code] Warning: vgui.Create failed to create the VGUI component (DImage)
[ERROR] lua/autorun/client/logoonhud.lua:11: attempt to index local 'Logo' (a nil value)
1. LogoOnHud - lua/autorun/client/logoonhud.lua:11
2. unknown - lua/autorun/client/logoonhud.lua:34
Default clips will be not be modified
--- Missing Vgui material texturemissing
[/code]
[QUOTE=peatreat;51143223]did it and got this error
[code] Warning: vgui.Create failed to create the VGUI component (DImage)
[ERROR] lua/autorun/client/logoonhud.lua:11: attempt to index local 'Logo' (a nil value)
1. LogoOnHud - lua/autorun/client/logoonhud.lua:11
2. unknown - lua/autorun/client/logoonhud.lua:34
Default clips will be not be modified
--- Missing Vgui material texturemissing
[/code][/QUOTE]
It worked when I tested it, make sure you haven't got an addon overriding DImage. ( [url]http://i.imgur.com/o41Cm7L.png[/url] )
Sorry, you need to Log In to post a reply to this thread.