Skip to content

Instantly share code, notes, and snippets.

@Rusketh
Forked from Xp3r7/gist:ac9a6e31666183ce0f2d
Last active August 29, 2015 14:05
Show Gist options
  • Save Rusketh/0824b18dd420bb7ca684 to your computer and use it in GitHub Desktop.
Save Rusketh/0824b18dd420bb7ca684 to your computer and use it in GitHub Desktop.
local ply = LocalPlayer
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "CCM"
ENT.Author = "Wire King"
ENT.Spawnable = true
ENT.AdminSpawnable = false
if SERVER then
function ENT:Initialize()
local R = math.random( 0, 255 )
local G = math.random( 0, 255 )
local B = math.random( 0, 255 )
self:SetHealth( 1000 )
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
self.Entity:SetSolid( SOLID_VPHYSICS )
self.Entity:SetColor( Color(R , G, B) )
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
function ENT:SpawnFunction( ply, tr, ClassName )
if ( !tr.Hit ) then return end
local ent = ents.Create( ClassName )
ent:SetPos( (tr.HitPos + tr.HitNormal * 20) )
ent:Spawn()
ent:Activate()
ent:SetModel( "models/props_junk/watermelon01.mdl" )
ent:SetOwner( ply )
end
function ENT:Think()
local R = math.random( 0, 255 )
local G = math.random( 0, 255 )
local B = math.random( 0, 255 )
self.Entity:SetColor( Color( R, G, B ) )
self.Entity:NextThink( CurTime() + 3 )
return true
end
end
if CLIENT then
function ENT:Draw()
self.Entity:SetMaterial( "model/shiny" )
self.Entity:DrawModel()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment