Welcome, Guest! Login | Register

CTF Gameplay Part 3 [Print this Article]
Posted by: DarkNight
Date posted: Apr 15 2003
User Rating: 5 out of 5.0
Number of views: 5660
Number of comments: 2
Description: Setting up Client side and FGD
This part of the tutorial will show you how to setup the client side and the FGD for the CTF Gamerules.

NOTE: This code will need modifying to suit your team system,ect so don't take this as a complete C&P (which it basically is).



Open up hl_events.cpp and find the following:
void EV_TripmineFire( struct event_args_s *args );
and put this after it:
 CODE  

void EV_Flag( struct event_args_s *args );



Next, in the same file, find:
gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire );
and after it put this:

 CODE  

gEngfuncs.pfnHookEvent( "events/object.sc", EV_Flag );


Next, in ev_hldm.cpp, find:
void EV_TripmineFire( struct event_args_s *args );
and at the end of that function put this:
 CODE  

void EV_Flag(struct event_args_s *args );



Same file, ev_hldm.cpp, find:
void EV_TripmineFire( event_args_t *args )
and at the end of that function put this:
 CODE  

#define FLAG_STOLEN 1
#define FLAG_CAPTURE    2
#define FLAG_DROPPED    3

void EV_Flag( event_args_t *args )
{
    int idx = args->entindex;
    int type = args->iparam1;


    // Feel free to change the model that is attached to the player

    int FlagModel = gEngfuncs.pEventAPI->EV_FindModelIndex("models/flag.mdl");

    switch( type )
    {
    case FLAG_STOLEN:

            // Attach model to player

            gEngfuncs.pEfxAPI->R_AttachTentToPlayer( idx, FlagModel, 52, 9999);
// The 52 is the z offset from
            the player and the 9999 is how long you want it to be attached for
            // Add more stuff here if you like

            break;
    case FLAG_CAPTURE:

            // Add stuff here if you like

    case FLAG_DROPPED:

            // Add more stuff here if you like
            // This gets rid of the attached model

            gEngfuncs.pEfxAPI->R_KillAttachedTents(idx);
            break;
    }
}



Now to setup the FGD we do the following at the bottom of the FGD:
 CODE  

@PointClass = object_flag: "The Flag" []
@SolidClass base(Targetx) = capture_team1: "Where Team 1 brings the Flag"
[
    m_iPoints(integer) : "Points" : 1
]
@SolidClass base(Targetx) = capture_team2: "Where Team 2 brings the Flag"
[
    m_iPoints(integer) : "Points" : 1
]



And that concludes my 3 Part tutorial on the CTF Gameplay. If you have any complaints, suggestions,problems,ect. Feel free to email me at the_dark_wonderer@hotmail.com

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

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

Posted By: AlperiNi on Jul 23 2005 at 00:18:30
Where I can find ctf_objects.h?

Posted By: Compi on Feb 27 2009 at 02:38:53
How to fix it?

--------------------Configuration: hl - Win32 Profile--------------------
Compiling...
teamplay_gamerules.cpp
C:\CleanSDK\SDK\SourceCode\dlls\teamplay_gamerules.cpp(372) : error C2065: 'pPlayer' : undeclared identifier
C:\CleanSDK\SDK\SourceCode\dlls\teamplay_gamerules.cpp(372) : error C2227: left of '->pev' must point to class/struct/union
C:\CleanSDK\SDK\SourceCode\dlls\teamplay_gamerules.cpp(372) : error C2227: left of '->netname' must point to class/struct/union
ctf_gameplay.cpp
C:\CleanSDK\SDK\SourceCode\dlls\ctf_gameplay.cpp(220) : error C2039: 'm_iTeam' : is not a member of 'CBasePlayer'
C:\CleanSDK\SDK\SourceCode\dlls\player.h(71) : see declaration of 'CBasePlayer'
C:\CleanSDK\SDK\SourceCode\dlls\ctf_gameplay.cpp(251) : error C2039: 'm_iTeam' : is not a member of 'CBasePlayer'
C:\CleanSDK\SDK\SourceCode\dlls\player.h(71) : see declaration of 'CBasePlayer'
C:\CleanSDK\SDK\SourceCode\dlls\ctf_gameplay.cpp(334) : error C2039: 'm_iTeam' : is not a member of 'CBasePlayer'
C:\CleanSDK\SDK\SourceCode\dlls\player.h(71) : see declaration of 'CBasePlayer'
C:\CleanSDK\SDK\SourceCode\dlls\ctf_gameplay.cpp(362) : error C2039: 'm_iTeam' : is not a member of 'CBasePlayer'
C:\CleanSDK\SDK\SourceCode\dlls\player.h(71) : see declaration of 'CBasePlayer'
Error executing cl.exe.

hl.dll - 7 error(s), 0 warning(s)


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: 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
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Persuter | 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: 3.0.0.9
Valid XHTML 1.0! Valid CSS!