NPC Spawn problem ents.Create( npc_alyx )



local function CarDealer( ply, text )
	if string.sub(text, 1, 7) == "/spawn" then
		local car = ents.Create("rm_car_dealer")
		car:SetPos( -2390.494141, -443.853668, -131.968750 )
		car:SetAngles( 0, 180, 0 )
		car:Spawn()
		car:SetDamage( 0 )
	end
end
hook.Add("OnPlayerChat", "NPCSpawn", CarDealer)


Ok apparently there’s something wrong with this bit of code but can’t seem to find what!



[ERROR] lua/autorun/client/commands.lua:46: attempt to call field 'Create' (a nil value)
  1. fn - lua/autorun/client/commands.lua:46
   2. Call - addons/ulib/lua/ulib/shared/hook.lua:183
    3. func - gamemodes/darkrp/gamemode/modules/chat/cl_chat.lua:28
     4. unknown - lua/includes/modules/net.lua:31


Is my error?
Please help

Try creating the entity on serverside instead.

Also
[lua]
car:SetPos(-2390.494141, -443.853668, -131.968750)
car:SetAngles(0, 180, 0)
[/lua]

Should be

[lua]
car:SetPos(Vector(-2390.494141, -443.853668, -131.968750))
car:SetAngles(Angle(0, 180, 0))
[/lua]

Ok iI’ll try I’ll get back to you if it works:P

[editline]23rd December 2013[/editline]

Didn’t work but how do I make it so it spawns every time the server restarts?

Use InitPostEntity hook.