diff --git a/src/client/util.h b/src/client/util.h index 064da614..2a0a5084 100644 --- a/src/client/util.h +++ b/src/client/util.h @@ -38,4 +38,8 @@ bool Client_InIntermission(void); string Util_GetKeyString(string strBind); /** Returns if the currently active client-seat is in a vehicle. */ -bool Client_InVehicle(void); \ No newline at end of file +bool Client_InVehicle(void); + +string Util_GetTime(void); +float Util_GetTimeLeft(void); +string Util_GetAddress(void); \ No newline at end of file diff --git a/src/client/util.qc b/src/client/util.qc index e9152d27..e183cef4 100644 --- a/src/client/util.qc +++ b/src/client/util.qc @@ -90,3 +90,46 @@ Util_GetMaxPlayers(void) { return g_numplayerslots; } + +string +Util_GetTime( void ) +{ + static int iS, iM, iT, iMS; + float timeLimit = stof( serverkey( "timelimit" ) ) * 60; + + /* display a count-down timer if we've got a time limit */ + if (timeLimit <= 0) + iMS = (int)time; + else + iMS = timeLimit - time; + + if ( iMS < 0 ) { + iMS = 0; + } + + iS = iMS; + iM = iS / 60; + iS -= iM * 60; + iT = iS / 10; + iS -= iT * 10; + + return sprintf( "%i:%i%i", iM, iT, iS ); +} + +float +Util_GetTimeLeft(void) +{ + float timeLimit = stof( serverkey( "timelimit" ) ) * 60; + return timeLimit - time; +} + +string +Util_GetAddress(void) +{ + string host = serverkey("ip"); + + if (host == "QLoopBack:0") + return "localhost"; + else + return host; +} \ No newline at end of file