So my shop NPC is basically done, all I have to do is make the buying part work, check jobs, and spawn the ships if they are a certain job, but anyway, my main issue is that when someone opens the menu, all my derma images are missing textures, so it looks really bad, I’m not sure how to put my custom images in the server content to make it show for other people. Here are the files:
init.lua
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/tfa/comm/gg/npc_cit_sw_droid_tactical.mdl")
self:SetHullType( HULL_HUMAN );
self:SetHullSizeNormal();
self:SetSolid( SOLID_BBOX )
self:SetMoveType( MOVETYPE_STEP )
self:CapabilitiesAdd(CAP_TURN_HEAD + CAP_ANIMATEDFACE)
self:SetHullType(HULL_HUMAN)
self:SetHullSizeNormal()
self:SetUseType( SIMPLE_USE )
self:SetMaxYawSpeed( 5000 )
self:SetSequence(ACT_IDLE)
end
util.AddNetworkString("OpenMenu")
util.AddNetworkString("BuyDelta")
util.AddNetworkString("BuyVWing")
util.AddNetworkString("BuyYWing")
function ENT:AcceptInput(input, activator, caller)
if input == "Use" || IsValid(caller:IsPlayer()) then
net.Start("OpenMenu")
net.Send(caller)
end
end
function ENT:OnTakeDamage()
if CurTime() > self.PainSoundT then
self:EmitSound("vo/npc/male01/pain0"..math.random(1,9)..".wav")
self.PainSoundT = CurTime() + 1
end
end
net.Receive("BuyDelta", function(len, ply)
entity = ents.Create("delta7")
entity:SetAngles(Angle(0, 180, 0))
entity:SetPos(ply:EyePos() + ply:GetAngles():Right() * 350 + Vector(-30, 0, 10))
entity:Spawn()
timer.Simple( .25, function()
PrintMessage(HUD_PRINTTALK, "Your ship has been delivered.")
end)
end)
net.Receive("BuyVWing", function(len, ply)
entity = ents.Create("v-wing")
entity:SetAngles(Angle(0, 180, 0))
entity:SetPos(ply:EyePos() + ply:GetAngles():Right() * 350 + Vector(-30, 0, 10))
entity:Spawn()
timer.Simple( .25, function()
PrintMessage(HUD_PRINTTALK, "Your ship has been delivered.")
end)
end)
net.Receive("BuyYWing", function(len, ply)
entity = ents.Create("y-wing")
entity:SetAngles(Angle(0, 180, 0))
entity:SetPos(ply:EyePos() + ply:GetAngles():Right() * 350 + Vector(-30, 0, 10))
entity:Spawn()
timer.Simple( .25, function()
PrintMessage(HUD_PRINTTALK, "Your ship has been delivered.")
end)
end)
cl_init.lua
include("shared.lua")
ENT.RenderGroup = RENDERGROUP_BOTH
surface.CreateFont( "Shop Title", {
font = "coolvetica",
size = 55,
weight = 1000,
antialias = true,
} )
surface.CreateFont( "DLabel", {
font = "coolvetica",
size = 30,
weight = 1000,
antialias = true,
} )
surface.CreateFont( "DButton", {
font = "coolvetica",
size = 25,
weight = 1000,
antialias = true,
} )
surface.CreateFont( "Price", {
font = "coolvetica",
size = 25,
weight = 1000,
antialias = true,
} )
net.Receive("OpenMenu", function()
local frame = vgui.Create("DFrame")
frame:SetSize(1035 ,800)
frame:Center()
frame:MakePopup()
frame:SetScreenLock(true)
frame:ShowCloseButton(false)
frame:SetTitle("")
function frame:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w+10, h+10, Color( 0, 0, 0 ) )
draw.RoundedBox(5,5,5,w-10,h-10,Color(111,111,111))
end
local YWing = vgui.Create( "DImage", frame )
YWing:SetPos( 5, 5 )
YWing:SetSize( 1025, 790 )
YWing:SetImage("M:/SteamLibrary/steamapps/common/GarrysMod/garrysmod/materials/spawnicons/models/StarWarsShips/Hangar.png")
local Shape = vgui.Create( "DShape", frame )
Shape:SetType( "Rect" ) -- This is the only type it can be
Shape:SetPos( 10, 20 )
Shape:SetColor( Color( 66, 66, 66 ) )
Shape:SetSize( 1015, 70 )
function Shape:Paint( w, h )
draw.RoundedBox( 80, 2, 2, w, h, Color( 0, 0, 0, 255 ) )
draw.RoundedBox(6,6,6,w-10,h-10,Color(66,66,66, 75))
end
local text = vgui.Create("DLabel", frame)
text:SetText("Hey there, so you wanna try your hand at piloting? Go ahead.")
text:SetPos(175, 25)
text:SetFont("DLabel")
text:SetColor(Color(255, 144, 0))
text:SetSize(1000, 30)
local text2 = vgui.Create("DLabel", frame)
text2:SetText("Here is a list of ships you can buy.")
text2:SetPos(325, 55)
text2:SetFont("DLabel")
text2:SetColor(Color(255, 144, 0))
text2:SetSize(1000, 30)
local rgb = Color
local DScrollPanel = vgui.Create( "DScrollPanel", frame )
DScrollPanel:SetSize( 565, 300 )
DScrollPanel:SetPos( 5, 500 )
DScrollPanel:Dock( FILL )
DScrollPanel:Center()
local sbar = DScrollPanel:GetVBar()
function sbar:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, rgb(52, 73, 94,100) )
end
function sbar.btnUp:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, rgb(192, 57, 43) )
end
function sbar.btnDown:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, rgb(192, 57, 43) )
end
function sbar.btnGrip:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, rgb(44, 62, 80) )
end
local Shape2 = vgui.Create( "DShape", frame )
Shape2:SetType( "Rect" ) -- This is the only type it can be
Shape2:SetPos( 10, 100 )
Shape2:SetColor( Color( 66, 66, 66 ))
Shape2:SetSize( 250, 550 )
function Shape2:Paint( w, h )
draw.RoundedBox( 4, 2, 2, w, h, Color( 0, 0, 0, 150 ) )
draw.RoundedBox(6,6,6,w-10,h-10,Color(66,66,66, 150))
end
local button = vgui.Create("DButton", frame)
button:SetSize(350,125)
button:SetPos(355, 660)
button:SetTextColor(Color(255,144,0))
button:SetText("Don't wanna buy a ship?")
button:SetFont("DButton")
button.DoClick = function()
frame:Close()
end
function button:Paint( w, h )
draw.RoundedBox( 4, 2, 2, w, h, Color( 0, 0, 0, 150 ) )
draw.RoundedBox( 40, 2, 2, w, h, Color( 0, 0, 0, 150 ) )
draw.RoundedBox(6,6,6,w-10,h-10,Color(66,66,66, 150))
end
local Shape3 = vgui.Create( "DShape", frame )
Shape3:SetType( "Rect" ) -- This is the only type it can be
Shape3:SetPos( 275, 100 )
Shape3:SetColor( Color( 66, 66, 66 ))
Shape3:SetSize( 750, 550 )
function Shape3:Paint( w, h )
draw.RoundedBox( 4, 2, 2, w, h, Color( 0, 0, 0, 150 ) )
draw.RoundedBox( 40, 2, 2, w, h, Color( 0, 0, 0, 150 ) )
draw.RoundedBox(6,6,6,w-10,h-10,Color(66,66,66, 150))
end
local button = vgui.Create("DButton", frame)
button:SetSize(200,150)
button:SetPos(35, 125)
button:SetText("Buy a Delta")
button:SetFont("DButton")
button:SetColor(Color(255,144,0))
button.DoClick = function()
net.Start("BuyDelta")
net.SendToServer()
frame:Close()
end
function button:Paint( w, h )
draw.RoundedBox( 4, 2, 2, w, h, Color( 0, 0, 0) )
draw.RoundedBox( 40, 2, 2, w, h, Color( 0, 0, 0) )
draw.RoundedBox(6,6,6,w-10,h-10,Color(66,66,66))
end
local text2 = vgui.Create("DLabel", frame)
text2:SetText("Cost: $250")
text2:SetPos(80, 215)
text2:SetFont("Price")
text2:SetColor(Color(255, 144, 0))
text2:SetSize(1000, 30)
local button2 = vgui.Create("DButton", frame)
button2:SetSize(200,150)
button2:SetPos(35, 300)
button2:SetText("Buy a V-Wing")
button2:SetFont("DButton")
button2:SetColor(Color(255,144,0))
button2.DoClick = function()
net.Start("BuyVWing")
net.SendToServer()
frame:Close()
end
function button2:Paint( w, h )
draw.RoundedBox( 4, 2, 2, w, h, Color( 0, 0, 0) )
draw.RoundedBox( 40, 2, 2, w, h, Color( 0, 0, 0) )
draw.RoundedBox(6,6,6,w-10,h-10,Color(66,66,66))
end
local text2 = vgui.Create("DLabel", frame)
text2:SetText("Cost: $250")
text2:SetPos(80, 390)
text2:SetFont("Price")
text2:SetColor(Color(255, 144, 0))
text2:SetSize(1000, 30)
local button3 = vgui.Create("DButton", frame)
button3:SetSize(200,150)
button3:SetPos(35, 475)
button3:SetText("Buy a Y-Wing")
button3:SetColor(Color(255,144,0))
button3:SetFont("DButton")
button3.DoClick = function()
net.Start("BuyYWing")
net.SendToServer()
frame:Close()
end
function button3:Paint( w, h )
draw.RoundedBox( 4, 2, 2, w, h, Color( 0, 0, 0) )
draw.RoundedBox( 40, 2, 2, w, h, Color( 0, 0, 0) )
draw.RoundedBox(6,6,6,w-10,h-10,Color(66,66,66))
end
local text2 = vgui.Create("DLabel", frame)
text2:SetText("Cost: $250")
text2:SetPos(80, 565)
text2:SetFont("Price")
text2:SetColor(Color(255, 144, 0))
text2:SetSize(1000, 30)
local DeltaImage = vgui.Create( "DImage", frame )
DeltaImage:SetPos( 300, 110 )
DeltaImage:SetSize( 250, 175 )
DeltaImage:SetImage("M:/SteamLibrary/steamapps/common/GarrysMod/garrysmod/materials/spawnicons/models/StarWarsShips/DeltaShip.png")
local VWing = vgui.Create( "DImage", frame )
VWing:SetPos( 300, 300 )
VWing:SetSize( 225, 175 )
VWing:SetImage("M:/SteamLibrary/steamapps/common/GarrysMod/garrysmod/materials/spawnicons/models/StarWarsShips/V-wing_BF2.png")
local YWing = vgui.Create( "DImage", frame )
YWing:SetPos( 300, 500 )
YWing:SetSize( 250, 125 )
YWing:SetImage("M:/SteamLibrary/steamapps/common/GarrysMod/garrysmod/materials/spawnicons/models/StarWarsShips/Y-Wing_Bomber.png")
local Label1 = vgui.Create("DLabel",frame)
Label1:SetPos(600, 110)
Label1:SetFont("DButton")
Label1:SetText("The Delta is a Jedi's choice fighter that")
Label1:SetSize(400, 100)
Label1:SetColor(Color(255,144,0))
local Label11 = vgui.Create("DLabel",frame)
Label11:SetPos(685, 135)
Label11:SetFont("DButton")
Label11:SetText("is both small and fast.")
Label11:SetSize(400, 100)
Label11:SetColor(Color(255,144,0))
local Label2 = vgui.Create("DLabel",frame)
Label2:SetPos(600, 300)
Label2:SetFont("DButton")
Label2:SetText("The V-Wing is a small, nimble ship")
Label2:SetSize(400, 100)
Label2:SetColor(Color(255,144,0))
local Label3 = vgui.Create("DLabel",frame)
Label3:SetPos(645, 325)
Label3:SetFont("DButton")
Label3:SetText("that is great for training.")
Label3:SetSize(400, 100)
Label3:SetColor(Color(255,144,0))
local Label4 = vgui.Create("DLabel",frame)
Label4:SetPos(600, 500)
Label4:SetFont("DButton")
Label4:SetText("The Y-Wing is a large, but nice")
Label4:SetSize(400, 100)
Label4:SetColor(Color(255,144,0))
local Label5 = vgui.Create("DLabel",frame)
Label5:SetPos(630, 525)
Label5:SetFont("DButton")
Label5:SetText("ship for doing bomb runs.")
Label5:SetSize(400, 100)
Label5:SetColor(Color(255,144,0))
end)
hook.Add("PostDrawOpaqueRenderables", "NpcTitle", function()
for _, ent in pairs (ents.FindByClass("testnpc")) do
if ent:GetPos():Distance(LocalPlayer():GetPos()) < 800 then
local plyAng = LocalPlayer():GetAngles()
local ang = Angle(0, plyAng.y - 180, 0)
ang:RotateAroundAxis(ang:Forward(), 90)
ang:RotateAroundAxis(ang:Right(), -90)
cam.Start3D2D(ent:GetPos() + ent:GetForward() + ent:GetUp() * 85, ang, 0.1)
draw.RoundedBox(4, -155, -22, 310, 55, Color(10, 10, 10, 150))
draw.SimpleText( "Ship Merchant", "Shop Title", 0, -25, Color(0, 139, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
cam.End3D2D()
end
end
end)
shared.lua
ENT.Type = "ai"
ENT.Base = "base_ai"
ENT.PrintName = " Dark's NPC "
ENT.Instructions = "Ship Merchant, Special thanks to -ICE- to not only helping me, but for being such a legend in the process."
ENT.Category = "Dark's Custom Entities"
ENT.Spawnable = true
ENT.AdminSpawnable = true
Also any help with checking which job/team the player is on would be appreciated. Only want certain people using this