Author Topic: Need help with NPC  (Read 2706 times)

0 Members and 1 Guest are viewing this topic.

Offline kropp

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Need help with NPC
« on: November 16, 2011, 07:17:29 PM »
I have a npc which I use for buying ammo in my Garrysmod server but the NPC stopped spawning after the newer update it works on single player but not when I upload it to my server.

Code: [Select]
AddCSLuaFile('cl_init.lua')
AddCSLuaFile('shared.lua')
include('cl_init.lua')

function ENT:Initialize( )
 
     self.Entity:PhysicsInit(SOLID_VPHYSICS) 
     self.Entity:SetMoveType(MOVETYPE_STEP) 
     self.Entity:SetSolid(SOLID_BBOX) 
     self:SetUseType( SIMPLE_USE )

self:SetMaxYawSpeed( 90 ) --Sets the angle by which an NPC can rotate at once.

end

function ENT:OnTakeDamage()
return false -- This NPC won't take damage from anything.
end

function ENT:AcceptInput( Name, Activator, Caller )
local RP = RecipientFilter()
RP:RemoveAllPlayers()
RP:AddPlayer( ents.GetByIndex(Caller:EntIndex()))
umsg.Start("GLD20", RP)
umsg.String(Caller:UniqueID())
umsg.End()
end

function RemoveNPCs()

if NPC:IsValid() then
NPC:Remove();
end

if NPC2:IsValid() then
NPC2:Remove();
end

NPC1 = ents.Create("AmmoNPC");
NPC1:SetPos(Vector(1282,-1318,-131)); --Vector( x, y, z )
NPC1:SetAngles(Angle(0, 177, 0));
NPC1:Spawn()
NPC1:SetModel("models/Humans/Group01/male_06.mdl");

NPC2 = ents.Create("SpeechBubble");
NPC2:SetPos(Vector(1282,-1318,-100)); --Vector( x, y, z )
NPC2:SetAngles(Angle(0, 177, 0));
NPC2:Spawn()
NPC2:SetModel("models/extras/info_speech.mdl");
end
hook.Add( "InitPostEntity", "spawnnpcs", SpawnNPCs)

timer.Create( "my_timer", 120, 0, function()
RemoveNPCs();
end )

hook.Add("Tick","SpinMeLol",function()
    NPC2:SetAngles(NPC5:GetAngles() + Angle(0,2,0))
end)

local function RemoveGunMachine()
    for _, v in pairs(ents.FindByName("gunshop_gunmaker_buttons")) do
        v:Remove()
    end
end
hook.Add( "InitPostEntity", "RemoveGunMachine", RemoveGunMachine )


If you can see a error in this code please tell me

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Need help with NPC
« Reply #1 on: November 20, 2011, 02:27:15 PM »
Are you getting any errors in the server console?
Experiencing God's grace one day at a time.