How would I make this entity get the weapon data of lets say the ak47,
and then print the data (like primary damage) in 3d2d?
This is what I have written up so far xD
[lua]include("shared.lua")
surface.CreateFont( "Gun1", {
font = "Bebas Neue",
size = 150,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true
} )
surface.CreateFont( "Gun2", {
font = "Bebas Neue",
size = 24,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true
} )
local function DrawTheNiggerText()
local ply = LocalPlayer()
if !ply or !ply:IsValid() then return end
local tr = ply:GetEyeTrace()
local ang = ply:EyeAngles()
if tr.Hit and tr.Entity:IsValid() and tr.Entity:GetClass() == "svt_40" then
cam.Start3D2D( tr.Entity:GetPos(), Angle( 0, ang.y - 90, 90 ), 0.1 )
draw.RoundedBox( 0, -120, - 300, 550, 145, Color( 42, 42, 42, 100 ) )
draw.SimpleText( "GUN INFO HERE", "Gun1", 155, - 225, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
cam.End3D2D()
end
end
hook.Add("PostDrawOpaqueRenderables", "svt_40", DrawTheNiggerText)[/lua]
Gun = ply:GetActiveWeapon()
CurrentClip = Gun:Clip1()
Name = Gun.PrintName
You can follow the example of the PrintName to get any detail of the SWEP.
To return a table of the player's weapons do ply():GetWeapons()
I dont quite understand what you're saying there, could you post an example?
So he helps you and you rate him dumb because you don't understand close to basic lua?
No i meant to rate him late because my friend told me how to fix it, i miss clicked
My friends idea didn't work anyways rofl.
His post isn't dumb i just didn't know how to change it haha.
Anyways don't flame, instead you could help?
In that case, basically you first get the weapon itself by defining wep as the current weapon that the player has in his hands:
[lua]
local wep = ply:GetActiveWeapon()
[/lua]
Then you can get all sorts of infromation.
For example get the name of the weapon:
[lua]
local wep = ply:GetActiveWeapon()
print(wep.PrintName)
[/lua]
That's about it.
I want it to print the data of a specific weapon not in the players hand.
Such as lets say an AK47.
Then I want to be able to put that in draw.SimpleText() so when I look at the entity
it will draw the ak47's information above it. Such as ammo/name/damage yadda yadda.
Thats what I was trying to say xD
Use ply:GetWeapons() to return a table of all the players weapons, then separate them out.
[lua]
for k, v in pairs( ply:GetWeapons() ) do
if v:GetClass() == "weapon_ak47" then
// draw text
end
end
[/lua]
Nonono Lets say he doesnt even own a ak47....
But when he looks at the entity it shows the ak47 stats.
I think he's looking for something like [url="http://coderhire.com/scripts/view/603"]this[/url]
You'll need to get a trace from the player. Something like this would do
[lua]local tr = LocalPlayer():GetEyeTrace()
if IsValid( tr.Entity ) and tr.Entity:IsWeapon() then
--Do stuff here, tr.Entity is the weapon
end[/lua]
So, basically what you already have, just change the class check to an ent:IsWeapon() check
No I want the entity to print the data of a AK47 without having to be an AK47
Oh my god I finally understand.
[lua]wep = weapons.Get( "weapon_ak47" )[/lua]
Then you can do what I've said above.
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index01d1.html[/url]
Ok so what you're trying to do is a gunlab-type-thing that displays the stats of its manufactured weapon?
OMG Internet1001, thank you!
BAZINGA YOU'RE THE WINNER >:D
Sorry, you need to Log In to post a reply to this thread.