• Custom entity not coliding or registering being used.
    6 replies, posted
  • Avatar of cloudwolf
  • So as the title says my entity is unable to be colided with as in i can simply walk through it. Also i am unable to press use on it. The walking throuhg it doesn't bug me as much as it not registering my use as i need it to register that for my gamemode to work how i intend it to. init.lua [lua]AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") function ENT:Initialize() self.Entity:SetModel("models/weapons/w_357.mdl") self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHSYICS) local phys= self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() print("its awake") else print("its dead jim") end self.Entity:GetPhysicsObject():EnableGravity(false) timer.Simple(.01,function() self.Entity:SetPos(self.Entity:GetPos()+Vector(0,0,32)) end) timer.Create("spinit"..self.Entity:EntIndex(),.01,0,function() self.Entity:SetAngles(self.Entity:GetAngles()+Angle(0,1,0)) end) end function ENT:use(acti, caller) local samecount= 0 for k,v in pairs(acti:GetWeapons()) do if v:GetClass() == "better_pistol" then samecount= samecount+1 end end if samecount>=1 then acti:GiveAmmo(100,"Pistol",true) elseif #acti:GetWeapons()<2 then acti:Give("decent_pistol") else acti:StripWeapon(acti:GetActiveWeapon():GetClass()) acti:Give("decent_pistol") end timer.Remove("spinit"..self.Entity:EntIndex()) self.Entity:Remove() end function ENT:Think() end[/lua] cl_init.lua [lua]include("shared.lua") function ENT:Draw() self.Entity:DrawModel() end[/lua] and last but not least shared.lua [lua]ENT.Type= "anim" ENT.Base= "base_gmodentity" ENT.PrintName = "spinning starter pistol" ENT.Author = "cloudwolf" ENT.Contact= "not provided" ENT.Purpose="give people weapons and looking cool" ENT.Instructions ="f*ck the instructions"[/lua] Btw the ent flaots how high i want it and spins how i want it. It doesn't give me any errors in console and i have no idea why its not working.
  • Avatar of ers35.
  • You misspelled "SOLID_VPHYSICS" on line 10 of init.lua and "Use" needs to be capitalized on line 23. It will work once you correct these errors.
  • Avatar of cloudwolf
  • ers35. Thank you it figures that i skipped over some small spelling errors. I hate typing physics i keep doing phsyics... That's what i get for typing to fast. And I completely spaced over that capital. Thank you so much.
  • Avatar of Emz
  • Do you use Notepad++ by any chance? If so download the Lua Syntax Highlighter Plugin. It is great for detecting typos if certain key words aren't highlighted. Syntax highlighter can be found here: [url]http://www.facepunch.com/showthread.php?t=477505[/url] Looks like this: [img]http://img110.imageshack.us/img110/8054/highlight.png[/img]
  • Avatar of cloudwolf
  • I use NP++ but i have the gmod syntax highlighter but it keeps telling me it doesn't work with my version of NP++ so unless the verison you ilnked is compatable with 5.4.3
  • Avatar of Emz
  • Well I use v5.4.2 and it works fine for me on that version. I checked about for some links and couldn't find a newer version of the highlighter sorry. Try it and see if it works?