• exploding sofa!? HELP :D
    72 replies, posted
  • Avatar of lolfish
  • Hi im a litle noob at lua. i just wonder how i can create a sofa which explosing when a player geting near it :D hehe maby little wierd but i just want to try :D plz help :>
  • Avatar of Nick99
  • Do you want it to explode when a player is within a certain proximity(say 200 units) or when it is touched? [QUOTE=conman420;13635561]How does one explose?[/QUOTE] His first language might not be english.
  • Avatar of XHeadHunterX
  • I could bet he's french, I'm saying this because it is my first language and "exploser" means "to explode". It shouldn't be a big deal, just use ents.Create( "env_explosion" ) when the player is at X,Y of the prop.
  • [lua]function ENT:Think() for id,pl(in pairs(player.GetAll())do if( pl:GetPos():Distance(self:GetPos()) < 400 )then --EXPLODING COAD HERE self:Remove() break; end end end[/lua]ur welcome
  • Avatar of eryk
  • Is fucking Easy [code] AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') ENT.LASTINGEFFECT = 45; function ENT:SpawnFunction(ply, tr) if (!tr.Hit) then return end local ent = ents.Create("exploding_sofa") // Fucking important change it to you folder name!!! ent:SetPos(tr.HitPos + Vector(0,0,15)) ent:Spawn() ent:Activate() ent:SetName("exploding sofa") return ent end function ENT:OnRemove() end function ENT:Initialize() self.Entity:SetModel("models/props_junk/watermelon01.mdl") self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) self.Entity:SetCollisionGroup( COLLISION_GROUP_PLAYER ) local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() phys:SetMass(1) end end function ENT:Explode() local explode = ents.Create( "env_explosion" ) explode:SetPos( self.Entity:GetPos() ) explode:Spawn() explode:SetKeyValue( "iMagnitude", "220" ) explode:Fire( "Explode", 0, 0 ) explode:EmitSound( "weapon_AWP.Single", 400, 400 ) self.Entity:Remove() end function ENT:StartTouch() self.Entity:Explode() end function ENT:OnRemove() end function ENT:Use() end function ENT:Use() end [/code] If you don't change it to folder name then it don't work!!!! CL_INIT! [code] include('shared.lua') [/code] SHARED!!! [code] ENT.Base = "base_anim" ENT.Type = "anim" ENT.Category = "Exploding things!" ENT.PrintName = "Exploding Sofa" ENT.Author = "Victi" // Change to you name :D ENT.Contact = "Fuck OFF" ENT.Purpose = "Helping Lolfish" ENT.Instructions = "" ENT.Spawnable = true ENT.AdminSpawnable = true [/code] here is You Sofa it Will Work (Work Fine For me :D) Remenber to change model And the IMPORTANT!!! You Folders Name!!! [code] local ent = ents.Create("exploding_sofa") // Fucking important change it to you folder name!!! [/code] That!! There Have you the Exploding Sofa :D
  • Avatar of Overv
  • [QUOTE=victi;13642795]Stuff[/QUOTE] Your coding style seriously makes me cry. BRB Lemme write better code.
  • Avatar of eryk
  • [QUOTE=Overv;13643166]Your coding style seriously makes me cry. BRB Lemme write better code.[/QUOTE] !-.-! Thx For That !That is my coding style have you a problem!
  • Avatar of Overv
  • Create a folder 'Exploding Sofa' in addons and add an info.txt file, here's mine: [code]"AddonInfo" { "name" "Exploding Sofa" "version" "1.0" "author_name" "Overv" "author_url" "http://www.overvprojects.nl" "info" "An exploding sofa" }[/code] Now, create a folder 'lua' and in that folder a folder 'entities' and in that folder a folder 'exploding_sofa'. Now create the following files in that folder and you're done: shared.lua [lua]ENT.Base = "base_anim" ENT.Type = "anim" ENT.Category = "Explosive SENTS" ENT.PrintName = "Exploding Sofa" ENT.Author = "Overv" ENT.Contact = "overv161@gmail.com" ENT.Purpose = "A sofa that explodes when a player gets within a certain range" ENT.Instructions = "Just put it somewhere and it'll work." ENT.Spawnable = true ENT.AdminSpawnable = true[/lua] cl_init.lua [lua]include( "shared.lua" )[/lua] init.lua [lua]//Distribute files to clients AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) //Include shared entity information include( "shared.lua" ) //Constants EXPLODE_DISTANCE = 256 //Maximum safe distance before it explodes function ENT:SpawnFunction( ply, tr ) if !tr.Hit then return end //Create the entity local sofa = ents.Create( "exploding_sofa" ) sofa:SetPos( tr.HitPos + Vector(0, 0, 15) ) sofa:Spawn() sofa:Activate() sofa:SetName( "Exploding Sofa" ) sofa:SetOwner( ply ) //Add the owner so it doesn't explode when the owner is near //Also add it to the client's undo list undo.Create( "prop" ) undo.AddEntity( sofa ) undo.SetPlayer( ply ) undo.Finish() return ent end function ENT:Initialize() //Setting up the entity model and physics settings local sofa = self.Entity sofa:SetModel( "models/props_c17/FurnitureCouch001a.mdl" ) sofa:PhysicsInit( SOLID_VPHYSICS ) sofa:SetMoveType( MOVETYPE_VPHYSICS ) sofa:SetCollisionGroup( COLLISION_GROUP_PLAYER ) end function ENT:Think() for _, ply in pairs(player.GetAll()) do if ply:GetPos():Distance( self.Entity:GetPos() ) < EXPLODE_DISTANCE and ply != self.Entity:GetOwner() then self.Entity:Explode() end end end function ENT:Explode() //Create the explosion local explosion = ents.Create( "env_explosion" ) explosion:SetPos( self.Entity:GetPos() ) explosion:Spawn() explosion:SetKeyValue( "iMagnitude", 220 ) explosion:Fire( "Explode", 0, 0 ) //Remove the entity self.Entity:Remove() end[/lua] The sofa will explode when a player other than the owner gets within EXPLODE_DISTANCE of the sofa. The creator can undo it with 'z' like always. Hope I've helped you out [img]http://d2k5.com/sa_emots/emot-dance.gif[/img]
  • Avatar of eryk
  • Maybe You Have a Better Scripting Style But The 2 Codes Works
  • Avatar of lolfish
  • Thanks ;D im srry for my bad english only so u know im from sweden xD Thanks a lot ;D wee :)
  • Avatar of eryk
  • But Lolfish Learn Lua You can't get the people to make the things for you [url]www.garrysmod.com/wiki[/url] Learn there In the Start is a litle bit hard to understant but is easy when you now how :D I hope my code and this helped you
  • Avatar of Overv
  • [QUOTE=lolfish;13644188]Thanks ;D im srry for my bad english only so u know im from sweden xD Thanks a lot ;D wee :)[/QUOTE] I know someone from Sweden who's 13 years old and speaks perfect English so that's bullshit. @victi: Maybe we helped him a bit too much [img]http://d2k5.com/sa_emots/rolleyes.gif[/img]
  • Avatar of lolfish
  • [QUOTE=victi;13644295]But Lolfish Learn Lua You can't get the people to make the things for you [url]www.garrysmod.com/wiki[/url] Learn there In the Start is a litle bit hard to understant but is easy when you now how :D I hope my code and this helped you[/QUOTE] Yeah its helped a lot thanks ;D you are best :)
  • Avatar of eryk
  • [QUOTE=Overv;13644306]I know someone from Sweden who's 13 years old and speaks perfect English so that's bullshit. @victi: Maybe we helped him a bit too much [img]http://d2k5.com/sa_emots/rolleyes.gif[/img][/QUOTE] Yea i think too [img]http://d2k5.com/sa_emots/rolleyes.gif[/img] He has learned nothing whe have maked it for him And if you need to get my code to work put the file on lua/entities I have don't maked it to a addon but you have a example from OverV But Good Luck Whit Learning Lua
  • Avatar of lolfish
  • hwo can i test the lua :D? in gmod. hehe this is the first time i testing script in lua :) i downloaded notepad++ yesterday >.<
  • Avatar of eryk
  • Very Easy Go on you Pc things C/Programs/Steam/SteamApps/Username/Garrysmod/Garrysmod/lua In the Lua folder there is some other folder put the code there if it is a ent then on the folder entities Is there When i Test My Entities, Weapon, autorun What ever I not 100% on the file names i have a pc *Danish version* Im from denmark But If you are from sweden maybe you have the same names C/Programer/Steam/SteamApps/Garrysmod/Garrysmod/lua/ I hope it helps
  • Avatar of eryk
  • play sanbox single/multi then if it work then you can spawn it or maybe it gives error i don't now what you mean 100%
  • Avatar of lolfish
  • [QUOTE=victi;13644497]play sanbox single/multi then if it work then you can spawn it or maybe it gives error i don't now what you mean 100%[/QUOTE] nope i cnat find it D: :(
  • Avatar of lolfish
  • [QUOTE=victi;13644528]where put you the folder??[/QUOTE] i followed overv instructions D: maby i did something wrong :(?
  • Avatar of eryk
  • Mnn try my code (Init, cl_init, shared) then put it on lua/entities also OverV's Code should work too but don't now how you do? also where you put it but follow that i say
  • [QUOTE=victi;13644295]But Lolfish Learn Lua You can't get the people to make the things for you [url]www.garrysmod.com/wiki[/url] Learn there In the Start is a litle bit hard to understant but is easy when you now how :D I hope my code and this helped you[/QUOTE] You ask for more help then anybody else on the forums....
  • Avatar of LiamBrown
  • [url]http://wiki.garrysmod.com/wiki/?title=Ricky%27s_Example_SENT[/url] follow that, it might help.
  • Avatar of lolfish
  • [QUOTE=epic-lulz;13644555]You ask for more help then anybody else on the forums....[/QUOTE] yea im srry D: u guys dont need to answer if u want :(
  • Avatar of eryk
  • [QUOTE=epic-lulz;13644555]You ask for more help then anybody else on the forums....[/QUOTE] I don't care if he don't ask about that on the threat i help him anyway
  • Avatar of lolfish
  • [QUOTE=victi;13644587]I don't care if he don't ask about that on the threat i help him anyway[/QUOTE] :D
  • [QUOTE=lolfish;13644570]yea im srry D: u guys dont need to answer if u want :([/QUOTE] I was talking to victi