Alright so here goes the most depressing thread I'll hopefully ever have to make...
I've been trying to create an entity for my gamemode but for some reason ENT:Use() OR ENT:AcceptInput() won't get called.
[B]init.lua[/B]
[code]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include("shared.lua")
function ENT:Initialize()
self:SetModel( "models/props_interiors/BathTub01a.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:SetUseType(SIMPLE_USE)
local phys = self:GetPhysicsObject()
if phys:IsValid() then phys:Wake() end
print("INITIALIZE RAN")
end
function ENT:Use(activator, caller)
print("Please dude... just print")
end
function ENT:AcceptInput(name, activator, caller, data)
print("Please dude... just print")
end
[/code]
[B]shared.lua[/B]
[code]
ENT.Base = "base_ai"
ENT.Type = "anim"
ENT.PrintName = "Outfit NPC"
ENT.Author = "Vloxan"
ENT.Spawnable = true
ENT.AdminSpawnable = true
ENT.Category = "Lobby"
[/code]
[B]cl_init.lua[/B]
[code]
include("shared.lua")
function ENT:Draw()
self:DrawModel()
end
[/code]
I'm deriving from the base gamemode although I've been told by two people this shouldn't cause an issue and it doesn't seem like Use or AcceptInput are Sandbox functions.
The files are successfully running because the model is drawn, and the print statement on initialization also works, and also I am able to spawn the entity.
Apologies if I've made any really obvious mistakes here (which I expect I have, how complicated can it be lol), been a bit mentally out of it this week whilst programming and this has all ended up as a bit of a headache for myself.
did you try using [url]Thecodingbeast.com[/url] apparently they're the best for darkrp
How are you spawning the entity? Do you walk through it when it's spawned? Are you using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetOwner]Entity:SetOwner[/url]?
Show us the spawning code.
Consider using filezilla
Prior to your post I was not setting owner.
I just added SetOwner now as you'll see below although now I walk through it which may also make Use not work I'm assuming?
[code]
local ent = ents.Create( "npc_outfit" )
if !IsValid( ent ) then return end
ent:SetPos(Entity(1):GetPos())
ent:SetOwner(Entity(1))
ent:Spawn()
[/code]
[QUOTE=John Reese;51551545]Prior to your post I was not setting owner.
I just added SetOwner now as you'll see below although now I walk through it which may also make Use not work I'm assuming?
[code]
local ent = ents.Create( "npc_outfit" )
if !IsValid( ent ) then return end
ent:SetPos(Entity(1):GetPos())
ent:SetOwner(Entity(1))
ent:Spawn()
[/code][/QUOTE]
Nevermind then, usually when people complain about entities not able to be used or shot at it's because the coder is using SetOwner which disables collisions, but that doesn't seem to be your case here, you can remove it.
I just stuck my gamemode in singleplayer and it worked...
This is interesting to say the least.
Edit: Oh poop now I need to update SRCDS :v:
Edit 2: Success! It works on my local SRCDS server now. Instinctively you'd say I probably didn't restart my server during the trouble shooting but I did various times so I'm not sure what happened there. Thanks for the help Jvs!
Sorry, you need to Log In to post a reply to this thread.