Skip to content

Instantly share code, notes, and snippets.

@Xp3r7
Last active August 29, 2015 14:05
Show Gist options
  • Save Xp3r7/ac9a6e31666183ce0f2d to your computer and use it in GitHub Desktop.
Save Xp3r7/ac9a6e31666183ce0f2d to your computer and use it in GitHub Desktop.
local ply = Player
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:SetCreator( ply )
undo.Create( "Amazing Melon" )
undo.AddEntity( ent )
undo.SetPlayer( ply )
undo.Finish()
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
hook.Add( "PlayerSay", "ChatCMD", function()
local text = string.lower( text )
string.sub( text, 1, 5 ) == "hello" then
chat.AddText( Color( 255, 255, 0 ), "Hi there!" )
end )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment