Attempted to create unknown entity type "npc_property_buy" !
1 replies, posted
Hi all,
So i succeeded to make door owning system, and now i'm making an NPC to buy every type of property in rp_evocity_v33x.
I defined a table on my gamemode shared.lua to link door EntIndex() to a property, or to a public door. Now i'm on my way to make the npc gui when use it.
So i defined my npc in garrysmod/gamemodes/realistic_roleplay/entities/npc_property_buy/.
I made 3 files : init.lua (server init), cl_init.lua (client init) and shared.lua.
You need to know before i post codes, i'm calling method and vars that are defined in the gamemode (GameGlobal is a useful set of usefull methods, ...)
cl_init.lua
[code]
include('shared.lua')
ENT.RenderGroup = RENDERGROUP_BOTH
function ENT:Draw()
self.Entity:DrawModel( )
end
net.Receive("ShowBuyPropertyFrame", function(len, pl)
CreateDialogPanel()
end)
function CreateDialogPanel()
--Defining main display frame
local mainFrame = vgui.Create("DFrame")
mainFrame:SetPos(50, 50)
mainFrame:SetSize(812, 512)
mainFrame:SetVisible(true)
mainFrame:SetTitle("Buy a property...")
mainFrame:SetDraggable(true)
mainFrame:ShowCloseButton(true)
local propertyList = vgui.Create("DComboBox", mainFrame)
propertyList:SetPos(10, 35)
propertyList:SetSize(128, 412)
propertyList:SetMultiple(false)
for k, v in pairs(properties) do
propertyList:AddItem(v.name)
end
local displayPanel = vgui.Create("DPanel", mainFrame)
displayPanel:SetPos(140, 35)
displayPanel:SetSize(650, 412)
displayPanel.Paint = function()
surface.SetDrawColor(Color(0, 0, 0, 255))
surface.DrawRect(0, 0, 650, 412)
end
--TestingComboBox:GetSelectedItems()[1]
mainFrame:MakePopup()
end
[/code]
shared.lua
[code]
ENT.Base = "base_ai"
ENT.Type = "ai"
ENT.PrintName = "Buy Property"
ENT.Author = "Yuri6037"
ENT.Category = "Realistic_Roleplay"
ENT.Contact = "contact@stonelins.fr"
ENT.Purpose = "N/A"
ENT.Instructions = "Press A"
ENT.AutomaticFrameAdvance = true
function ENT:SetAutomaticFrameAdvance( bUsingAnim )
self.AutomaticFrameAdvance = bUsingAnim
end
[/code]
init.lua
[code]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')
GameGlobal:PrintMessage("Initializing buy_property_npc...")
function ENT:Initialize()
self:SetModel("models/Barney.mdl")
self:SetHullType(HULL_HUMAN)
self:SetHullSizeNormal()
self:SetNPCState(NPC_STATE_SCRIPT)
self:SetSolid(SOLID_BBOX)
self:CapabilitiesAdd(CAP_ANIMATEDFACE)
self:CapabilitiesAdd(CAP_TURN_HEAD)
self:SetUseType(SIMPLE_USE)
self:DropToFloor()
self:SetMaxYawSpeed(90)
end
util.AddNetworkString("ShowBuyPropertyFrame")
function clientOpenFrame()
net.Start("ShowBuyPropertyFrame")
net.Broadcast()
end
function ENT:Use(activator, caller)
clientOpenFrame()
end
function ENT:OnTakeDamage(dmg)
return false
end
[/code]
So "properties" table is defined in gamemode shared.lua witch is included to every clients on the server. So both server and client can access the file. It contains infos such as jobs infos, defined properties, npc_property_buy location, and some else.
[editline]29th June 2014[/editline]
Please, i need help... I don't unerstand why the server won't load that entity...
Why nobody has answers ?
Nobody has ever tried to make a property seller NPC ? Are you just wanting to ignore me ? Do you just don't know what's happening ?
Sorry, you need to Log In to post a reply to this thread.