[QUOTE=skar;37600086]Is there a way to give draw.RoundedBox an outline?[/QUOTE]
Quick way is to draw another box behind it with the outline color:
[lua]draw.RoundedBox( 4, 100, 100, 50, 50, Color( 0, 0, 0, 255 ) )
draw.RoundedBox( 4, 102, 102, 46, 46, Color( 255, 255, 255, 255 ) )[/lua]
However that will mess up any transparency, if you want to avoid that you'll have to make a function yourself to draw just the outline, use surface.DrawLine for the straight bits and then some basic trig for the rounded corners.
is there a way to tell my player to walk to given coordinates? no need for pathing, cause the way would only be a few steps each movement..
[QUOTE=brandonj4;37598312]Use this:
[lua]
function SWEP:CheckWeaponsAndAmmo()
local wep = self.Weapon
local owner = self.Owner
if wep:Clip1() == 0 && owner:GetAmmoCount(wep:GetPrimaryAmmoType()) == 0 then
timer.Simple(0.2, NotYours, owner)
end
end
function SWEP:NotYours()
local owner = self.Owner
owner:StripWeapon(self.Weapon:GetClass())
end
[/lua][/QUOTE]
[lua]Timer Error: attempt to call a nil value
[/lua]
thanks anyway :(
[QUOTE=me-name-bob;37603302][lua]Timer Error: attempt to call a nil value
[/lua]
thanks anyway :([/QUOTE]
[lua]
timer.Simple(0.2, self.NotYours, owner)
[/lua]
[QUOTE=James xX;37604157][lua]
timer.Simple(0.2, self.NotYours, self, owner)
[/lua]
[IMG]http://www.facepunch.com/fp/ratings/lua_helper.png[/IMG][/QUOTE]
Still no luck.
[lua]Timer Error: [<bullshit>\shared.lua:129] attempt to call method 'StripWeapon' (a nil value)
[/lua]
Thanks though.
Is there a good way to do this by a script in the gamemode?
[QUOTE=Drakehawke;37601365]Quick way is to draw another box behind it with the outline color:
[lua]draw.RoundedBox( 4, 100, 100, 50, 50, Color( 0, 0, 0, 255 ) )
draw.RoundedBox( 4, 102, 102, 46, 46, Color( 255, 255, 255, 255 ) )[/lua]
However that will mess up any transparency, if you want to avoid that you'll have to make a function yourself to draw just the outline, use surface.DrawLine for the straight bits and then some basic trig for the rounded corners.[/QUOTE]
They're transparent, so do you know of an equation or how to make an equation that I can just input x for the roundedbox border and it would draw that curve? I failed trig :p
[QUOTE=skar;37605324]They're transparent, so do you know of an equation or how to make an equation that I can just input x for the roundedbox border and it would draw that curve? I failed trig :p[/QUOTE]
Here's what I use:
[lua]
function draw.DrawArc( x, y, radius, a, a2 )
for ang = a, a2, 1 do
local x1 = -radius * math.cos( math.rad( ang ) )
local y1 = -radius * math.sin( math.rad( ang ) )
local x2 = -radius * math.cos( math.rad( ang + 1 ) )
local y2 = -radius * math.sin( math.rad( ang + 1 ) )
surface.DrawLine( x + x1, y + y1, x + x2, y + y2 )
end
end
function draw.RoundedBoxOutline( radius, x, y, w, h, color, thickness )
surface.SetDrawColor( color )
for i = 1, thickness, 1 do
draw.DrawArc( x + radius, y + radius, radius, 0, 90 )
draw.DrawArc( x + w - radius, y + radius, radius, 90, 180 )
draw.DrawArc( x + radius, y + h - radius, radius, 270, 360 )
draw.DrawArc( x + w - radius, y + h - radius, radius, 180, 270 )
surface.DrawLine( x + radius, y, x + w - radius, y )
surface.DrawLine( x + w, y + radius, x + w, y + h - radius )
surface.DrawLine( x + radius, y + h, x + w - radius, y + h )
surface.DrawLine( x, y + radius, x, y + h - radius )
x = x + 1
y = y + 1
w = w - 2
h = h - 2
end
end[/lua]
[QUOTE=Drakehawke;37605572]Here's what I use:
[lua]
function draw.DrawArc( x, y, radius, a, a2 )
for ang = a, a2, 1 do
local x1 = -radius * math.cos( math.rad( ang ) )
local y1 = -radius * math.sin( math.rad( ang ) )
local x2 = -radius * math.cos( math.rad( ang + 1 ) )
local y2 = -radius * math.sin( math.rad( ang + 1 ) )
surface.DrawLine( x + x1, y + y1, x + x2, y + y2 )
end
end
function draw.RoundedBoxOutline( radius, x, y, w, h, color, thickness )
surface.SetDrawColor( color )
for i = 1, thickness, 1 do
draw.DrawArc( x + radius, y + radius, radius, 0, 90 )
draw.DrawArc( x + w - radius, y + radius, radius, 90, 180 )
draw.DrawArc( x + radius, y + h - radius, radius, 270, 360 )
draw.DrawArc( x + w - radius, y + h - radius, radius, 180, 270 )
surface.DrawLine( x + radius, y, x + w - radius, y )
surface.DrawLine( x + w, y + radius, x + w, y + h - radius )
surface.DrawLine( x + radius, y + h, x + w - radius, y + h )
surface.DrawLine( x, y + radius, x, y + h - radius )
x = x + 1
y = y + 1
w = w - 2
h = h - 2
end
end[/lua][/QUOTE]
thanks, i'll post screenshots of the finished menu in waywo later this week.
Here's another one: [url]https://wiremod.svn.sourceforge.net/svnroot/wiremod/trunk/wire/lua/entities/gmod_wire_egp/lib/objects/roundedboxoutline.lua[/url]
But it looks like his is more optimized for what you're trying to do
[QUOTE=Divran;37606072]Here's another one: [url]https://wiremod.svn.sourceforge.net/svnroot/wiremod/trunk/wire/lua/entities/gmod_wire_egp/lib/objects/roundedboxoutline.lua[/url]
But it looks like his is more optimized for what you're trying to do[/QUOTE]
looks way over-complicated, drake's should work just fine for this purpose.
thanks anyways though <3
[QUOTE=me-name-bob;37604594]Still no luck.
[lua]Timer Error: [<bullshit>\shared.lua:129] attempt to call method 'StripWeapon' (a nil value)
[/lua]
Thanks though.
Is there a good way to do this by a script in the gamemode?[/QUOTE]
StripWeapon is a null function because Owner is a null entity (or nil (more likely on second thought)) and is therefore lacking the StripWeapon function by the time it is called. My guess is it somehow gets called twice or something, after the weapon has already been stripped. Anyway, quick fix to stop the error spam:
[lua]
function SWEP:CheckWeaponsAndAmmo()
if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 then
timer.Simple(.01, self.NotYours, self)
end
end
function SWEP:NotYours()
if self.Owner != nil then
if self.Owner:IsValid() then
self.Owner:StripWeapon(self.Gun)
end
end
end
[/lua]
Just added some checks before trying to strip the weapon. Untested, but should work
I think it's null because he's running the code clientside, StripWeapon is serverside.
[QUOTE=Undefined;37606887]I think it's null because he's running the code clientside, StripWeapon is serverside.[/QUOTE]
Correct me if I'm wrong, but isn't the SWEP a shared file? I.E, it runs both client side and server side
[QUOTE=Trumple;37607108]Correct me if I'm wrong, but isn't the SWEP a shared file? I.E, it runs both client side and server side[/QUOTE]
Yeah, and he's probably calling SWEP:CheckWeaponsAndAmmo() without doing a server check, so it also gets called clientside.
[QUOTE=Undefined;37607162]Yeah, and he's probably calling SWEP:CheckWeaponsAndAmmo() without doing a server check, so it also gets called clientside.[/QUOTE]
That would explain why it works and also gives an error.
[QUOTE=Undefined;37607162]Yeah, and he's probably calling SWEP:CheckWeaponsAndAmmo() without doing a server check, so it also gets called clientside.[/QUOTE]
Ah ha. I haven't done any SWEP scripting before, excuse my lack of knowledge. What you said sounds right. If its being called on both the client and the server, then the client will get the error and the server will actually do it
<snip>
It looks like even after the weapon is taken away, the methos is stilled called. Any ideas why this would be called more than once?
EDIT: And it looks like you answered before I even asked, thanks. Next time, I'll remember to check the next page.
I'm going to do some fooling around some more, and update real soon.
[QUOTE=me-name-bob;37607799]Still no luck. [lua]Timer Error: [<bullshit>\shared.lua:128] attempt to call method 'StripWeapon' (a nil value)
[/lua]
It looks like even after the weapon is taken away, the methos is stilled called. Any ideas why this would be called more than once?[/QUOTE]
Read the posts above yours.
[QUOTE=vercas;37607822]Read the posts above yours.[/QUOTE]
yeah, you caught the post just before I updated it haha. My bad, I'll report back shortly.
How would I replace the hud for vanilla sandbox?
I already made a custom hud based off of alien swarm and fallout but I have no idea what to save it as.
And I got a winner!
[lua]
function SWEP:CheckWeaponsAndAmmo()
if SERVER then
if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 then
timer.Simple(.01, self.NotYours, self)
end
end
end
function SWEP:NotYours()
self.Owner:StripWeapon(self.Gun)
end[/lua]
Weapon strips, no errors, all is right with the world. Thanks guys, I really appreciate all the help.
[img]http://puu.sh/13E2w[/img]
anyone know why TTT is ignoring the rearm file?
[QUOTE=Banana Lord.;37608072][img]http://puu.sh/13E2w[/img]
anyone know why TTT is ignoring the rearm file?[/QUOTE]
no but i want to play on your ttt server
send me ip babe
[QUOTE=Banana Lord.;37608072][img]http://puu.sh/13E2w[/img]
anyone know why TTT is ignoring the rearm file?[/QUOTE]
you need the newest TTT version. Found at the TTT website.
Can someone please point me to a good tutorial/example on stencils and render targets and just some of the more advanced render library functions? I've been stuck in the same place for hours now.
[QUOTE=Charrax;37608517]you need the newest TTT version. Found at the TTT website.[/QUOTE]
gmod doesn't ship with it?
[QUOTE=Banana Lord.;37608609]gmod doesn't ship with it?[/QUOTE]
Gmod ships with v27 not v28
[QUOTE=Charrax;37608772]Gmod ships with v27 not v28[/QUOTE]
yep, see that now, thanks!
Not a single person is willing to help me? :(
Sorry, you need to Log In to post a reply to this thread.