Why doesn't my sent work?

  • snip - OP is too long, refer to the bottom for current problem.

There is a lot wrong with your code. You’re missing most of the code required for entities.
Your shared.lua shouldn’t be empty and it can’t be found, because empty files aren’t sent.

You should take a look at this:

Ok, I got the ent working now. I have only 2 issues, when I use the ent it opens the menu a shit ton of times and the ent is up in the air. Any ideas?

[editline]21st January 2011[/editline]

it actually sends the usermessage 10 times.

That’s because ENT:Use( ply ) is called a lot. Use this funtion to change how ENT.User is called:
**[Entity.SetUseType

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.SetUseType)**
I suggest you use SIMPLY_USE.

Ok, one minute, let me test.

[editline]21st January 2011[/editline]

Ok, that worked. Now what about it floating in a T-shape? Why does it do that?

You’re using a player model. Try using models/Humans/Group01/Female_02.mdl

I replaced it with that path and get this

I had to push escape so I could gyazo it.

Can you post the Initialize code?

[lua]function ENT:Initialize()
self:SetModel(“models/Humans/Group01/Female_02.mdl”)
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_NONE )
self:SetSolid( SOLID_VPHYSICS )
self:SetUseType( SIMPLE_USE )

local phys = self:GetPhysicsObject()
if phys:IsValid() then
	phys:Wake()
end

end[/lua]

mostly stolen from the wiki

self:SetHullType( HULL_HUMAN )
self:SetHullSizeNormal()

Add those.

Still in the air D:

You have to set the animation. Look at this: http://wiki.garrysmod.com/?title=NPC_Shop_Tutorial

Ok so I added and changed some shit and she is now on the ground, however I can no longer use her and I can walk right through her. any ideas? I will paste my files:

init.lua
[lua]
AddCSLuaFile(“cl_init.lua”)
AddCSLuaFile(“shared.lua”)

include(“shared.lua”)

function ENT:Initialize()
self:SetModel(“models/Humans/Group01/Female_02.mdl”)
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_NONE )
self:SetSolid( SOLID_VPHYSICS )
self:SetUseType( SIMPLE_USE )
self:SetHullType( HULL_HUMAN )
self:SetHullSizeNormal()
self:SetNPCState( NPC_STATE_SCRIPT )
self:CapabilitiesAdd( CAP_ANIMATEDFACE | CAP_TURN_HEAD )
self:DropToFloor()

--local phys = self:GetPhysicsObject()
--if phys:IsValid() then
--	phys:Wake()
--end

end

function ENT:Use(ply, caller)
umsg.Start(“donator_menu”, ply)
umsg.End()
end[/lua]

cl_init
[lua]
–derma stuff, and includes
[/lua]

shared.lua

[lua]
ENT.Type = “ai”
ENT.Base = “base_gmodentity”

ENT.PrintName = “PERP Donater”
ENT.Author = “Deuces”
ENT.Contact = “N/A”
ENT.Purpose = “TO use for donating to Dark Syndicates”
ENT.Instructions = “Drop in your addons.”
/*
ENT.AutomaticFrameAdvance = true

function ENT:SetAutomaticFrameAdvance( bUsingAnim )
self.AutomaticFrameAdvance = bUsingAnim
end
[/lua]

Any thoughts on what is wrong?

You don’t need this:
[lua]
ENT.PrintName = “PERP Donater”
ENT.Author = “Deuces”
ENT.Contact = “N/A”
ENT.Purpose = “TO use for donating to Dark Syndicates”
ENT.Instructions = “Drop in your addons.”
[/lua]
But anyways I think the reason you can walk through her is because it’s has something to do with perp I think.
For your second problem make sure you add
[lua]usermessage.Hook(“donater_menu”,yourMenu)[/lua] in cl_init.
Oh yeah try changing:
[lua]ENT.Base = “base_gmodentity”[/lua] to [lua]ENT.Base = “base_ai”[/lua]

The menu worked when she was in the air, but now that she is on the ground it doesn’t work anymore as if the ENT:Use() isn’t being called or w/e.

[editline]22nd January 2011[/editline]

Also this is testing in single player, it’s not in a perp server yet.

[editline]22nd January 2011[/editline]

After changing the ENT.Base to base_ai nothing happened. I can still walk through her and I still can’t use it.

Try replacing
[lua]
function ENT:Use(ply, caller)
umsg.Start(“donator_menu”, ply)
umsg.End()
end
[/lua]
with this:
[lua]
function ENT:AcceptInput( Name, Activator, Caller )
if Name == “Use” and Caller:IsPlayer() then
umsg.Start(“donater_menu”, Caller)
umsg.End()
end
end
[/lua]

Now it’s making the sound as if I am using her, but nothing comes up.

[editline]22nd January 2011[/editline]

oh you spelt donator different then me.

can you please post the cl_init too because I think it has something do with the functions in there now.

the cl_init is fine, it only has a menu which looks and works perfectly. There is only 1 issue - I can walk through the NPC.

SO the menu shows up now?