Spawning Entities that are Drawn over a Model during SRCDS Startup
2 replies, posted
Hello. I first apologize for my probable noob question... I have searched and found ways to spawn simple props with the server via autorun but I need help with spawning a prop that has an entity over it...
I am working on a weather channel for my server and while most of it is borrowed code, I worked a bit to clean it up and make it a part of the server. I have it working as an item you can buy and move on your own, but I would like to freeze it and make it part of the map in certain areas...
It is an entity that has the usual cl_init, init shared, etc.. It uses a render target to display information, and I know it works cause as an item it displays fine..
This entity is being drawn over model: models/props/cs_office/TV_plasma.mdl
The gamemode uses this code to make it an item and with OnUse():
----------------------
if SERVER then
function ITEM.OnUse ( Player )
local prop = Player:SpawnProp(ITEM, "prop_tv");
if (!prop || !IsValid(prop)) then return false; end
prop:SetItemOwner(Player);
return true;
end
---------------
I don't know if seeing that code does any good (probably doesnt)... But if I have the folder prop_tv and with those files making all the needed stuff to draw.. What am I looking into to make it spawn with the server loading?
I hope my question makes sense, its almost 2am for me and i'm exhausted...
Thanks in Advance,
SofaKing!
Assuming prop_tv is your ent classname, use something like this, and substitute in your location, and angles.
[lua]
local function Init_SpawnTV(ply, command, args)
local tv = ents.Create("prop_tv")
if ValidEntity(tv) then
tv:SetPos(Vector( -3341.5051, -2028.0845, 179.6603))
tv:Spawn()
tv:SetMoveType(MOVETYPE_NONE)
tv:SetAngles(Angle(0,0,0))
end
end
hook.Add( "InitPostEntity", "SpawnTV", Init_SpawnTV)
[/lua]
jimbo, might want to use tv.Owner = ply or something, just in case u kno ;p
Sorry, you need to Log In to post a reply to this thread.