diff --git a/iw5/scripts/mp/_jump.gsc b/iw5/scripts/mp/_jump.gsc index 79b6339..a272ea7 100644 --- a/iw5/scripts/mp/_jump.gsc +++ b/iw5/scripts/mp/_jump.gsc @@ -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() { diff --git a/iw5/scripts/mp/_utility.gsh b/iw5/scripts/mp/_utility.gsh index bf189c3..1beab03 100644 --- a/iw5/scripts/mp/_utility.gsh +++ b/iw5/scripts/mp/_utility.gsh @@ -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