The Game Modding Community - Since 2001

Basic Scripted Entity for GMOD 13

A Config Script for Garry's Mod

54 lines | 2 kb | Raw Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
AddCSLuaFile()

DEFINE_BASECLASS( "base_anim")
ENT.PrintName = "Beer Entity" -- Name of entity
ENT.Information = "drink entity" -- Information of the entity
ENT.Category = "Half-Life 2 Food Pack" -- Category of your entity located in your entities category
ENT.Spawnable = true -- Spawnable or not
ENT.AdminOnly = false -- admin only or not
local Sound = Sound("physics/glass/glass_bottle_impact_hard1.wav")  -- sound ur entity will make if used
function ENT:SpawnFunction( ply, tr, ClassName ) -- makes it spawnable and stuff

        if ( !tr.Hit ) then return end

        local size = math.random( 16, 48 )

        local ent = ents.Create( ClassName )
        ent:SetPos( tr.HitPos + tr.HitNormal * size )

        ent:Spawn()
        ent:Activate()

        return ent

end

function ENT:Use( activator, caller ) -- what it does when u press E on it
    self:EmitSound( Sound )
        self:Remove()
   
        if ( activator:IsPlayer() ) then

                local health = activator:Health() -- activator
                activator:SetHealth( health + 20 ) -- how much health it adds
               

        end

end

function ENT:Initialize() -- reads it or something lol
        -- Sets what model to use
        self:SetModel( "models/props_junk/garbage_glassbottle001a.mdl" ) -- model of your entity
   
        -- Physics stuff adds physics and stuff to ur entity
        self:SetMoveType( MOVETYPE_VPHYSICS )
        self:SetSolid( SOLID_VPHYSICS )

        -- Init physics only on server, so it doesnt mess up physgun beam
        if ( SERVER ) then self:PhysicsInit( SOLID_VPHYSICS ) end

        -- Make prop to fall on spawn
        local phys = self:GetPhysicsObject()
        if ( IsValid( phys ) ) then phys:Wake() end
end
Promotional Content

Posts

None found

Embed

Share banner
Image URL:
HTML embed code:
BB embed code:
Markdown embed code:

Credits

Putting script together
[gsk]crossfire avatar
[gsk]crossfire username pic Joined 2y ago
Offline
162 points Ranked 21953rd
putting script together and adding stuff

Submitter

[gsk]crossfire avatar
[gsk]crossfire username pic Joined 2y ago
hey there bby.
162 points Ranked 21953rd

[gsk]crossfire avatar
[gsk]crossfire

Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!
Sign up to access this!

Category

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • Share on Google+

Stats

  • 3,386 Views
  • 0 Posts
  • 2y Submitted
  • 2y Modified

Scores

  • Not yet rated
Sign up to access this!

SEX! Ok, we got your attention. Mascot

GameBanana is one of the oldest mod sites on the net. Sign up and maximize your browsing experience.

  • Subscribe: Get notified of new submissions like this.
  • Say Thanks: Show your appreciation - send modders points.
  • Post: Give modders your thoughts on their work.
  • Vote: Help your favorite modders win monthly awards.
  • Rate: Rate mods and help them stand out.
  • Flag: Alert moderators and warn members of problems with mods.
  • Watch: Get notified when mods are updated.

Sound fun? Sign up now!

Already a Bananite? Login

bcp.crwdcntrl.net tracking pixel