Client: add new Util_ functons Util_GetTime, Util_GetTimeLeft and Util_GetAddress for the current server.
This commit is contained in:
parent
3b99cf7419
commit
373e844305
2 changed files with 48 additions and 1 deletions
|
@ -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);
|
||||
bool Client_InVehicle(void);
|
||||
|
||||
string Util_GetTime(void);
|
||||
float Util_GetTimeLeft(void);
|
||||
string Util_GetAddress(void);
|
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue