Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/sites/a/ on line 20
Wavelength | Your Game Editing Resource | An Entity like a CS Buy Zone
Welcome, Guest! Login | Register

An Entity like a CS Buy Zone [Print this Article]
Posted by: omega
Date posted: May 12 2003
User Rating: 4 out of 5.0
Number of views: 6787
Number of comments: 1
Description: aka, like a ladder.
A few days ago someone was asking in irc how to detect if a player is in jail or not for his mod. I had already written something like this for MMXHL a few years ago to disable WallJumping while inside the entity.

All of this is based off of the ladder code.

The first thing you need to do is pull up const.h and find CONTENTS_LADDER, and create your new content value; just use the next available number after contents_ladder. For this funcjail entity, i've created CONTENTS_JAIL.

The bulk of the code is inside triggers.cpp
Find CLadder and duplicate all of its functions and rename it to CFuncJail (or whatever is suitible for what you want to use it for)
All of the Customization steps are in comments below:

//============ func jail ==================

class CFuncJail : public CBaseTrigger
    void KeyValue( KeyValueData *pkvd );
    void Spawn( void );
    void Precache( void );

LINK_ENTITY_TO_CLASS( func_jail, CFuncJail ); //link func_jail to CFuncJail

void CFuncJail :: KeyValue( KeyValueData *pkvd )
    CBaseTrigger::KeyValue( pkvd );
void CFuncJail :: Precache( void )
    // Do all of this in here because we need to 'convert' old saved games
    pev->solid = SOLID_NOT;
    pev->skin = CONTENTS_JAIL; //make a new content type; go to CONTENTS_LADDER, add your new
    //content type with the next available number.
    if ( CVAR_GET_FLOAT("showtriggers") == 0 )
        pev->rendermode = kRenderTransTexture;
        pev->renderamt = 0;
    pev->effects &= ~EF_NODRAW;
void CFuncJail::Spawn( void )

    SET_MODEL(ENT(pev), STRING(pev->model));    // set size and link into world
    pev->movetype = MOVETYPE_PUSH;

Now i've added a boolean to CBasePlayer for the server dll to reference if the player is in jail or not.

bool m_bInJail;

Now in player.cpp i've added a check into PlayerPrethink to set the bool's state:

    if (UTIL_PointContents(pev->origin) == CONTENTS_JAIL)
        m_bInJail = true;
        m_bInJail = false;

Now in order for the mapper to place this entity, we'll need an entry in our mods FGD.

@SolidClass base(Targetname) = func_jail : "in jail while inside" []

Thats It. Quite simple huh?
As following my last tutorial i've started a new trend of my own; optional blocks of code, or reference!

Lets say you want to check this for movement purposes, you'll want to do this in pmove right? right. So in order to check if you're inside this entity inside pmove; all you have to do is use a check like:

if (pmove->PM_PointContents( pmove->origin, NULL ) == CONTENTS_JAIL ))
we're in jail!

any time you wan't to check it.

Rate This Article
This article is currently rated: 4 out of 5.0 (5 Votes)

You have to register to rate this article.
User Comments Showing comments 1-1

Posted By: TelimTor on Jun 03 2004 at 14:36:15
This article is really helpful...

*Edit* No, that's not sarcasm :PEdited by TelimTor on Jun 03 2004, 14:36:31

You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 05 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005

Latest Comments
knock knock
General | News
By: MIFUNE | Dec 31 2017
knock knock
General | News
By: omega | Dec 22 2016
knock knock
General | News
By: MIFUNE | Oct 10 2015
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
knock knock
General | News
By: Whistler | Nov 05 2011
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (5 guests)
About - Credits - Contact Us

Wavelength version:
Valid XHTML 1.0! Valid CSS!