[lua]
/*---------------------------------------------------------------------------
This is an example of a custom entity.
---------------------------------------------------------------------------*/
include("shared.lua")
function ENT:Initialize()
end
function ENT:Draw()
local ply = LocalPlayer()
self:DrawModel()
local dist = (ply:GetShootPos() - self.Entity:GetPos()):Length()
if (dist > 750) then return end
local angZ = (self.Entity:GetPos() - ply :GetShootPos())
local tr = util.GetPlayerTrace(ply , angZ)
local tr = util.TraceLine(tr)
local Pos = self:GetPos()
local Ang = self:GetAngles()
local Ang2 = self:GetAngles()
local owner = self:Getowning_ent()
owner = (IsValid(owner) and owner:Nick()) or DarkRP.getPhrase("unknown")
surface.SetFont("HUDNumber5")
local text = "AMMO SHOP"
local TextWidth ,TextHeight = surface.GetTextSize(text)
local TextWidth2,TextHeight2 = surface.GetTextSize(owner or "OWNER NAME")
local TextWidth3,TextHeight3 = surface.GetTextSize("SMG - $34")
local TextWidth4,TextHeight4 = surface.GetTextSize("Buckshot - $34")
local TextWidth5,TextHeight5 = surface.GetTextSize("Rifle - $34")
local TextWidth6,TextHeight6 = surface.GetTextSize("Pulse - $34")
local TextWidth7,TextHeight7 = surface.GetTextSize("Revolver - $34")
local TextWidth8,TextHeight8 = surface.GetTextSize("Pistol - $34")
Ang:RotateAroundAxis(Ang:Up(), 90)
Ang:RotateAroundAxis(Ang:Forward(), 0)
cam.Start3D2D(Pos + Vector(0,0,20), Ang, 0.11)
--draw.RoundedBox(2, -240,-125, 500,300, Color(0,0,50,100) )
-- draw.WordBox(2, -TextWidth*0.5, -30, text, "HUDNumber5", Color(0, 0, 255, 100), Color(255,255,255,255))
draw.WordBox(2, -TextWidth2*0.5, -90, owner, "HUDNumber5", Color(0, 0, 255, 100), Color(255,255,255,255))
draw.WordBox(2, -TextWidth*0.5, -85+TextHeight, text, "HUDNumber5", Color(0, 0, 255, 100), Color(255,255,255,255))
draw.WordBox(2, -200, -20+20,"SMG - $34", "HUDNumber5", Color(0, 0, 255, 100), Color(255,255,255,255))
draw.WordBox(2, -200, 10+20, "Buckshot - $34", "HUDNumber5", Color(0, 0, 255, 100), Color(255,255,255,255))
draw.WordBox(2, -200, 40+20, "Rifle - $34", "HUDNumber5", Color(0, 0, 255, 100), Color(255,255,255,255))
draw.WordBox(2, 0, 40+20, "Pulse - $34", "HUDNumber5", Color(0, 0, 255, 100), Color(255,255,255,255))
draw.WordBox(2, 0, 10+20, "Revolver - $34", "HUDNumber5", Color(0, 0, 255, 100), Color(255,255,255,255))
draw.WordBox(2, 0, -20+20, "Pistol - $34", "HUDNumber5", Color(0, 0, 255, 100), Color(255,255,255,255))
cam.End3D2D()
local smgAmmoButton = {x= -200,y =0,width=TextWidth3,height=TextHeight3}
local vectoronboard = util.IntersectRayWithPlane(ply:GetShootPos(), ply:GetAimVector(),self.Entity:GetPos() ,self.Entity:GetAngles():Forward())
local ToLocal = self:WorldToLocal(vectoronboard)
local PlaneStartLocal = self:WorldToLocal(self.Entity:GetAngles():Forward())
local PlaneAimXY = ToLocal-PlaneStartLocal
local x = math.floor(PlaneAimXY.x)
local y = math.floor(-PlaneAimXY.y)
if ToLocal == nil then print("its nil") return end
if (ToLocal.x > smgAmmoButton.x and ToLocal.x < smgAmmoButton.x+smgAmmoButton.width and ToLocal .y > smgAmmoButton.y and ToLocal.y < smgAmmoButton.y+smgAmmoButton.height) then
print("here")
if(LocalPlayer():KeyDown( IN_USE )) then
print("yes")
else
end
end
end
function ENT:Think()
end
[/lua]
I dont know how to make buttons for 3d2d. I have no idea how to get the position of the mouse relative to the 3d2d text. Can someone give a explination
I made a post about this a while ago:
[url]http://facepunch.com/showthread.php?t=1405662&p=45303545#post45303545[/url]
the most efficient way of finding if a player is looking at any arbitrary 2 dimensional rectangle shaped area that exists in 3d space.
Sorry, you need to Log In to post a reply to this thread.