ok so i have a entity here and im trying to make it pick up then put it in your inventory
init.lua
[code]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include( "shared.lua" )
function ENT:Initialize()
self.Entity:SetModel( getItems( self:GetNWString("itemName") ).model )
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity:SetUseType(SIMPLE_USE)
local phys = self.Entity:GetPhysicsObject()
if phys and phys:IsValid() then phys:EnableGravity(true) phys:Wake() end
end
function ENT:SetItemName( name )
self.itemName = name
end
function ENT:Use( activator, caller )
getItems( self:GetNWString("itemName") ).use(activator, self)
end
function ENT:Touch( ent )
end
function ENT:OnRemove()
end
function ENT:Think()
end[/code]
cl_init.lua
[code]include("shared.lua")
function ENT:Think()
end
function ENT:Draw()
self:DrawModel()
end[/code]
shared.lua
[code]ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "item"
ENT.Author = "xrayhunter"[/code]
Wouldn't you use the [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcdb2.html]ENT:Touch[/url] hook and run what you want in there. Since it returns the entity touching you can do something like this:
[lua]function ENT:Touch( ent )
if ( !ent:IsPlayer() ) then return end
-- If the item is a weapon:
ent:Give( self:GetClass() )
-- Then remove the entity
self:Remove()
end[/lua]
[QUOTE=Internet1001;42431358]Wouldn't you use the [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcdb2.html]ENT:Touch[/url] hook and run what you want in there. Since it returns the entity touching you can do something like this:
[lua]function ENT:Touch( ent )
if ( !ent:IsPlayer() ) then return end
-- If the item is a weapon:
ent:Give( self:GetClass() )
-- Then remove the entity
self:Remove()
end[/lua][/QUOTE]
well i dont want my players running around and then you get items and you didn't want them and there
inventory is full do you get i mean?
Ah, sorry, I can't read.
by the way this is unsolved! guys so try to help i still have the same code from last time
init.lua:
[code]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include( "shared.lua" )
function ENT:Initialize()
self.Entity:SetModel( getItems( self:GetNWString("itemName") ).model )
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity:SetUseType(SIMPLE_USE)
local phys = self.Entity:GetPhysicsObject()
if phys and phys:IsValid() then phys:EnableGravity(true) phys:Wake() end
end
function ENT:SetItemName( name )
self.itemName = name
end
function ENT:Use( activator, caller )
getItems( self:GetNWString("itemName") ).use(activator, self)
end
function ENT:Touch( ent )
end
function ENT:OnRemove()
end
function ENT:Think()
end
[/code]
cl_init.lua:
[code]
include("shared.lua")
function ENT:Think()
end
function ENT:Draw()
self:DrawModel()
end
[/code]
shared.lua:
[code]
ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "item"
ENT.Author = "xrayhunter"
[/code]
So what exactly is the problem? Does the entity not spawn? Does it not give people stuff?
making it not just go to your weapon bar in stand it goes to your inventory
Sorry, you need to Log In to post a reply to this thread.