• Entity Disguise Seller:
    3 replies, posted
The title says everything. I need help at coding my disguise seller. I want it like if you press E on the Disguise Seller he opens a DFrame where you can choose your disguise and I want it like to be 5000$ each disguise. I have problems at DFrame so hopefully you guys can help me on that. I also wanna add if you buy a disguise you have to wait 450 seconds till you can buy another. Last thing is that I only want the disguise seller beeing used by only THIEFS. Alright thats all hopefully you guys can help me. init.lua : AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua")  function ENT:Initialize() self:SetModel("models/props_c17/briefcase001a.mdl")  self:PhysicsInit(SOLID_VPHYSICS)  self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS)  self:SetUseType(USE_TOGGLE)  self:EmitSound("sounds/entities/siren.wav", 100, 100) local phys = self:GetPhysicsObject()  if (IsValid(phys) ) then  phys:Wake() end  end  function ENT:SpawnFunction(ply,tr,ClassName) if (!tr.Hit) then return end  local SpawnPos = ply:GetShootPos() + ply:GetForward() *10 local ent = ents.Create(ClassName)  ent:SetPos(SpawnPos)  ent:Spawn() ent:Activate()  return ent  end  function ENT:Use( ply, caller ) ply:SetModel("models/player/gasmask.mdl") print("Succesfully changed your playermodel!")         end  function ENT:Think() end   shared.lua : ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.Category = "Slice" ENT.PrintName = "Disguise Seller" ENT.Author = "SliceyPicey" ENT.Purpose = "Disguise" ENT.Instructions = "Place'n use." ENT.Spawnable = true  ENT.AdminSpawnable = true cl_init.lua : include("shared.lua")  function ENT:Draw()  self:DrawModel() end
You can open a DFrame on the client from ENT:Use by using the Net Library and networking to the player who used the entity. From there, you can just create the frame you want in a net.Receive callback in cl_init. When the player buys a disguise from the menu, network back to the server to give the disguise and put a cooldown on the player, which you can check in ENT:Use. The theives check can just be done alongside the cooldown checks. All-in-all, here's what your pseudocode looks like: init.lua AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua")  function ENT:Initialize() self:SetModel("models/props_c17/briefcase001a.mdl")  self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetUseType(SIMPLE_USE) self:EmitSound("sounds/entities/siren.wav", 100, 100) local phys = self:GetPhysicsObject()  if (phys:IsValid()) then  phys:Wake() end end  function ENT:SpawnFunction(ply, tr, ClassName) if (!tr.Hit) then return end  local SpawnPos = ply:GetShootPos() + ply:GetForward() * 10 local ent = ents.Create(ClassName)  ent:SetPos(SpawnPos)  ent:Spawn() ent:Activate()  return ent  end  function ENT:Use(_, caller) if (caller:IsPlayer()) then local flCooldown = caller.flDisguiseCooldown or 0 if (flCooldown <= CurTime()) then net.Start("DisguiseMenu") net.Send(caller) end end end util.AddNetworkString("DisguiseMenu") util.AddNetworkString("DisguiseBuy") net.Receive("DisguiseBuy", function(_, ply) local flCooldown = ply.flDisguiseCooldown or 0 local flCurTime = CurTime() if (flCooldown <= flCurTime) then -- Give disguise here ply.flDisguiseCooldown = flCurTime + 450 -- Add cooldown end end) cl_init.lua include("shared.lua")  net.Receive("DisguiseMenu", function() -- Create menu here, send net message to "DisguiseBuy" when the player buys end)
So I can basically make the DFrame here right?. And how do I make it like if I buy the disguise it automatically closed the DFrame. DFrame are my weakness is Lua. include("shared.lua") net.Receive("DisguiseMenu", function()-- Create menu here, send net message to "DisguiseBuy" when the player buysend)
Call DFrame/Close in your DButton's DoClick.
Sorry, you need to Log In to post a reply to this thread.