I'm trying to make a bleach entity that has the models/props_junk/garbage_plasticbottle002a.mdl model and kills you when you drink it, but what I've made so far just crashes me whenever I spawn it.
Here's the code
init.lua:
[CODE]AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/props_junk/garbage_plasticbottle002a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
local phys = self:GetPhysicsObject()
self.nodupe = false
phys:Wake()
end
function ENT:Use(activator,caller)
ply = activator
ply:Kill()
end
[/CODE]
shared.lua:
[CODE]ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Bleach"
ENT.Author = "Sethxi"
ENT.Spawnable = true
ENT.AdminSpawnable = false[/CODE]
Okay, your point?
[highlight](User was banned for this post ("help or don't post" - postal))[/highlight]
[QUOTE=Pazda;40028392]Okay, your point?[/QUOTE]
Solve it smart one
Could you supply us with the error you are getting? Garrysmod should output crashlogs when the game crashes.
[QUOTE=Lordgunner58;40029079]Could you supply us with the error you are getting? Garrysmod should output crashlogs when the game crashes.[/QUOTE]
It didn't give me any crashlogs, I just checked.
Code you're using to spawn it?
Comment stuff out until it doesn't crash?
[QUOTE=garry;40031704]Comment stuff out until it doesn't crash?[/QUOTE]
That's not really working..
Can someone just make me like a skeleton entity? with a use function that has a --do something here
[editline]30th March 2013[/editline]
[QUOTE=Drakehawke;40029684]Code you're using to spawn it?[/QUOTE]
I'm spawning it in the spawn menu..
[lua]
-- cl_init.lua
include( 'shared.lua' )
function ENT:Initialize()
end
function ENT:Draw()
self:DrawModel()
end
function ENT:Think()
end
[/lua]
[lua]
-- shared.lua
ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "Bleach"
ENT.Author = "King Flawless"
ENT.Purpose = "To kill"
ENT.Spawnable = true
ENT.AdminSpawnable = false
[/lua]
[lua]
-- init.lua
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
function ENT:Initialize()
self:SetModel("models/props_junk/garbage_plasticbottle002a.mdl")
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
end
function ENT:Use(activator,caller)
activator:Kill()
end
[/lua]
[QUOTE=Baig Flawless;40098235][lua]
include( 'shared.lua' )
function ENT:Initialize()
end
function ENT:Draw()
self:DrawModel()
end
function ENT:Think()
end
[/lua]
[lua]
ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "Bleach"
ENT.Author = "King Flawless"
ENT.Purpose = "To kill"
ENT.Spawnable = true
ENT.AdminSpawnable = false
[/lua]
[lua]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
function ENT:Initialize()
self:SetModel("models/props_junk/garbage_plasticbottle002a.mdl")
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
end
function ENT:Use(activator,caller)
activator:Kill()
end
[/lua][/QUOTE]
Which file is which exactly?
[QUOTE=Sethxi;40098355]Which file is which exactly?[/QUOTE]
Updated my post to show you
[editline]30th March 2013[/editline]
-snip- ninjad
[QUOTE=Sethxi;40098355]Which file is which exactly?[/QUOTE]
Sorry to say .. but If you don't know that, you shouldn't be making entities.
[QUOTE=Nak;40098432]Sorry to say .. but If you don't know that, you shouldn't be making entities.[/QUOTE]
Everyone starts somewhere,
[QUOTE=Baig Flawless;40098473]Everyone starts somewhere,[/QUOTE]
Maybe addon's or simple lua scripts where Gmod normally just returns an error, but messing with entities can in some case crash the client when making the slightest mistake.
[img_thumb]http://cloud-2.steampowered.com/ugc/541820807485752896/6492E2F9472C5901C9E2D1225B8C74BB1A53DBE3/1024x576.resizedimage[/img_thumb]
[QUOTE=Nak;40098534]Maybe addon's or simple lua scripts where Gmod normally just returns an error, but messing with entities can in some case crash the client when making the slightest mistake.[/QUOTE]
You can crash the client with addons and single scripts your point is invalid, your damage control is never going to be more than rolling back the code and restarting gmod.
The best way to learn is to change things and see what happens, you are always going to make mistakes but you learn from them and that is all that is important.
By the looks of it you forgot SpawnFunction.
[QUOTE=Baig Flawless;40098565]-snip-[/QUOTE]
Not my point, please reread my post, since it got nothing to do with how easy it is to crash Gmod. My point it's "[b]slightest mistake[/b]". As in it's best to learn handling client, server and shared side of files before moving on to something, that have to be nearly flawless. Besides this argument has 0% relevant for this thread.
[QUOTE=Robotboy655;40098580]By the looks of it you forgot SpawnFunction.[/QUOTE]
I would be shocked if that caused a crash i'm sure it will just spawn at 0,0,0 or throw an error but just incase put this in init.lua
[lua]
-- Ripped from sent_ball.lua
function ENT:SpawnFunction( ply, tr, ClassName )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( ClassName )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
[/lua]
Still crashes me.. wtf?
[QUOTE=Baig Flawless;40098628]I would be shocked if that caused a crash i'm sure it will just spawn at 0,0,0 or throw an error but just incase put this in init.lua
[/QUOTE]
Well, guess what, today I tried latest SVN version to try out NextBot npc, and upon spawning it though Entities tab the game frozen. Spawning it though NPCs tab worked. I am not sure. That entity doesn't have a SpawnFunction.
[QUOTE=Sethxi;40098660]Still crashes me.. wtf?[/QUOTE]
How are you spawning it post the code or what you are doing.
[editline]30th March 2013[/editline]
[QUOTE=Robotboy655;40098665]Well, guess what, today I tried latest SVN version to try out NextBot npc, and upon spawning it though Entities tab the game frozen. Spawning it though NPCs tab worked. I am not sure. That entity doesn't have a SpawnFunction.[/QUOTE]
I wouldn't be shocked if I was wrong, I rarely do any dev work in sandbox nor have I done any dev work in months.
Just tried adding a function ENT:SpawnFunction and it doesn't freeze anymore.
[editline]31st March 2013[/editline]
And as far as I gone into debugging it, it seems to freeze somewhere in CanPlayerSpawnSENT at sandbox/gamemode/commands.lua:544.
Maybe it's scripted_ents.GetMember?
[editline]31st March 2013[/editline]
I have come to a conclusion that at least in the SVN version scripted_ents.GetStored( EntityName ) causes a memory leak if entity doesn't have a SpawnFunction. This is kinda insane.
Having entities without a spawnfunction has always crashed me for a while now...
Similar behavior confirmed in normal version, except it doesn't actually create a memory leak.
Paste the errors and we might be able to help. Console errors if any are showing up.
Sorry, you need to Log In to post a reply to this thread.