I Have made a thread before on this, and got it figured out pretty good, but how can I make it something where like
If ENT (player) Stands on object for 7 seconds it runs a code, and if he stands on it for 5 mins and then steps off. it runs a code to
And if theres a way that by identyfing for example, Police Jerry and Robber Jerry. if police jerry stands on it it becomes blue once captured
and if robber jerry stands on it for 7 secs it becomes red
I know this is alot to ask for help with but any links to gmod wiki can help <3
Codes now :
cl_init
[CODE]include('shared.lua')
function ENT:Draw()
self.BaseClass.Draw(self)
self:DrawModel()
render.SetColorMaterial()
render.DrawSphere( self:GetPos(), 140, 40, 270, Color( 0, 175, 175, 100 ) )
end[/CODE]
init.lua
[CODE]AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside
AddCSLuaFile( "shared.lua" ) -- and shared scripts are sent.
include('shared.lua')
function ENT:Initialize()
self:SetModel( "models/hunter/plates/plate4x4.mdl" )
self:PhysicsInit( SOLID_VPHYSICS ) -- Make us work with physics,
self:SetMoveType( MOVETYPE_VPHYSICS ) -- after all, gmod is a physics
self:SetSolid( SOLID_VPHYSICS ) -- Toolbox
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
local BBOX = (self.max - self.min) / 2
self:SetSolid( SOLID_BBOX )
self:PhysicsInitBox( -BBOX, BBOX )
self:SetCollisionBoundsWS( self.min, self.max )
self:SetTrigger( true )
self:DrawShadow( false )
self:SetNotSolid( true )
self:SetNoDraw( false )
self.Phys = self:GetPhysicsObject()
if self.Phys and self.Phys:IsValid() then
self.Phys:Sleep()
self.Phys:EnableCollisions( false )
end
end
function ENT:StartTouch( ent)
end
function ENT:EndTouch( ent )
end
function ENT:Use( activator, caller )
return
end
function ENT:Think()
end
[/CODE]
shared.lua
[CODE]ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName= "A Flag"
ENT.Author= "Javs"
ENT.Contact= ""
ENT.Purpose= ""
ENT.Instructions= ""
ENT.Spawnable = true
ENT.AdminSpawnable = false[/CODE]
Sorry for all these questions, but im new to entity coding
I think you misunderstood my reply to your last thread.
The code I gave was an example of using an entity to set a zone.
It's meant to be a separate entity, and if you're gonna use DrawSphere, you should use PhysicsInitSphere. Alternatively, if you'er gonna use PhysicsInitBox, use render.DrawBox
As for your question:
StartTouch is called when an entity enters the zone, EndTouch is called when they leave the zone
Alright, I ll see what I can do
Sorry, you need to Log In to post a reply to this thread.