iw5: more macros
All checks were successful
Build / build-linux (push) Successful in 7s

This commit is contained in:
6arelyFuture 2024-03-20 18:38:22 +01:00
parent 8091ca53bb
commit 706408d20f
2 changed files with 22 additions and 9 deletions

View File

@ -12,11 +12,7 @@
GENERIC_INIT;
onPlayerConnect()
{
while ( true )
{
level waittill( "connected", player );
_ON_PLAYER_CNCT_BEGIN
#if defined(TOOL)
waittillframeend;
@ -35,8 +31,8 @@ onPlayerConnect()
player thread jumper();
player thread displaySpeed();
player thread onPlayerSpawned();
}
}
_ON_PLAYER_CNCT_END
displaySpeed()
{

View File

@ -26,6 +26,12 @@
#define TEMP_DVAR "temp_dvar_util"
#if defined(T4)
#define CLIENT_FIELD_NAME playername
#else
#define CLIENT_FIELD_NAME name
#endif
#define GENERIC_INIT \
init() \
{ \
@ -36,6 +42,17 @@
level endon( "game_ended" ); \
self endon( "disconnect" );
/* Captures a "connected" event. Perform your action(s) using the "player" variable */
#define _ON_PLAYER_CNCT_BEGIN onPlayerConnect() \
{ \
while ( true ) \
{ \
level waittill( "connected", player );
#define _ON_PLAYER_CNCT_END \
} \
}
/* IW4x MP has printConsole Built-in. __VA_OPT__ requires C++20 compliant preprocessor */
/* Do not use the + to concatenate strings, let the GSC VM do it for you */
/* Other clients will have print available */
@ -112,14 +129,14 @@
#define BOT_CHK(ent) \
if ( ent isTestClient() ) \
{ \
DEBUG_PRINT( ent.name + " is a bot\n" ); \
DEBUG_PRINT( ent.CLIENT_FIELD_NAME + " is a bot\n" ); \
CHK_ACTION; \
}
#else /* Valid for other clients */
#define BOT_CHK(ent) \
if ( isDefined( ent.pers["isBot"] ) && ent.pers["isBot"] ) \
{ \
DEBUG_PRINT( ent.name + " is a bot\n" ); \
DEBUG_PRINT( ent.CLIENT_FIELD_NAME + " is a bot\n" ); \
CHK_ACTION; \
}
#endif