• DarkRP - Spawned Entities owned by player.
    18 replies, posted
I'm trying to set up purchasing SCars through the F4 buy menu. I have AddEntity("Junker", "sent_sakarias_car_junker1", "models/props_c17/consolebox01a.mdl", 25000, 1, "/Junker", nil) And the car will spawn perfectly, My issue is that the car spawns as a world prop and I am unable to Lock/Unlock or undo the car. Does anyone have a way to set the car to spawn as owned by the player?
Have you tried spawning it without the f4 menu and seeing if you can own it?
Spawning through the SCars tab in the Q menu and using the SCars spawner tool both created the entity as owned by the player. The issue is the car being spawned though F4 being created as a worldprop and is un-editable by players, except for admins.
local ent = scripted_ents.GetStored("entity") ent.t:SpawnFunction(ply,ply:GetPos())
[QUOTE=lokienjaku;39249619]local ent = scripted_ents.GetStored("entity") ent.t:SpawnFunction(ply,ply:GetPos())[/QUOTE] Sorry for being a noob, but where exactly would I put that?
its makes it spawn like if you spawned it from the q menu of course the entity needs to have the spawnfunction in it
[QUOTE=lokienjaku;39250935]its makes it spawn like if you spawned it from the q menu of course the entity needs to have the spawnfunction in it[/QUOTE] I'm a noob and don't know exactly where I put that.
Yeah where do I put it?
well thats your spawn function but you got to add the spawnfunction function into your entity as well
[QUOTE=lokienjaku;39266783]well thats your spawn function but you got to add the spawnfunction function into your entity as well[/QUOTE] Made no sense where do I find this "Spawn Function"?
For spawn owned vehicles First you need to find a spawan fucntion Here my example for vehicles [LUA] concommand.Add("cardealer_spawncar", function(ply, cmd, args) vehicle.Owner = ply vehicle:Own(ply) vehicle:Spawn() vehicle:Activate() vehicle:Fire("lock") end) [/LUA] For single enteties init.lua [LUA] function ENT:Initialize() -- Your code -- local ply = self.dt.owning_ent self.SID = ply.SID self.SID = ply.SID self.Owner = ply end [/LUA] shared.lua[LUA]function ENT:SetupDataTables() self:DTVar("Entity",1,"owning_ent") end [/LUA]
[QUOTE=lua_error;39272526]init.lua [LUA] function ENT:Initialize() -- Your code -- local ply = self.dt.owning_ent self.SID = ply.SID self.SID = ply.SID self.Owner = ply end [/LUA] shared.lua [LUA] function ENT:SetupDataTables() self:DTVar("Entity",1,"owning_ent") end [/LUA][/QUOTE] Is there a way I can do this with out editing every single ent?
[QUOTE=vladka24;39272555]Is there a way I can do this with out editing every single ent?[/QUOTE] Yes for single I updated my post in general spawn all vehicles
[QUOTE=lua_error;39272586]Yes for single I updated my post in general spawn all vehicles[/QUOTE] So I put this in the addentities.lua? Kinda a noob ;D
No in entity that you need to be owned
[QUOTE=lua_error;39272674]No in entity that you need to be owned[/QUOTE] Wait then where do I put the code where it targets all cars?
Please help us :(
somebody help?
After digging into this issue myself I came up with a solution after making a old addon for my server. [CODE] spawn = function(ply, tr, tblEnt) [B]local ent = ents.Create( "NameOfEntity" ) ent:CPPISetOwner(ply)ent.SID = ply.SID ent.OwnerID = ply:SteamID() ent:SetPos( tr.HitPos + tr.HitNormal * 16 ) ent:Spawn() ent:Activate() return ent[/B] end [/CODE] Make yourself a entity on the darkrpmodification vehicles/entities tab. And then you want to insert [B]spawn =[/B] and the function I placed in bold above. I checked the internet and I think I maybe the first one to come with this solution. [B]For Those Who Are Clueless On Where To Put This. Here Is An Example:[/B] [url]http://wiki.darkrp.com/index.php/DarkRP:CustomShipmentFields[/url]
Sorry, you need to Log In to post a reply to this thread.