2022-07-07 09:10:14 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016-2022 Vera Visions LLC.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
2022-04-25 15:25:35 -07:00
|
|
|
|
2022-12-28 16:48:57 -08:00
|
|
|
bool
|
2022-05-11 12:49:04 -07:00
|
|
|
Client_IsSpectator(NSClient cl)
|
2022-04-25 15:25:35 -07:00
|
|
|
{
|
|
|
|
if (cl.IsRealSpectator() || cl.IsFakeSpectator())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-12-28 16:48:57 -08:00
|
|
|
bool
|
2022-05-11 12:49:04 -07:00
|
|
|
Client_IsRealSpectator(NSClient cl)
|
2022-04-25 15:25:35 -07:00
|
|
|
{
|
|
|
|
return cl.IsRealSpectator();
|
|
|
|
}
|
|
|
|
|
2022-12-28 16:48:57 -08:00
|
|
|
bool
|
2022-05-11 12:49:04 -07:00
|
|
|
Client_IsFakeSpectator(NSClient cl)
|
2022-04-25 15:25:35 -07:00
|
|
|
{
|
|
|
|
return cl.IsFakeSpectator();
|
|
|
|
}
|
|
|
|
|
2022-12-28 16:48:57 -08:00
|
|
|
bool
|
2022-05-11 12:49:04 -07:00
|
|
|
Client_IsDead(NSClient cl)
|
2022-04-25 15:25:35 -07:00
|
|
|
{
|
|
|
|
return cl.IsDead();
|
|
|
|
}
|
|
|
|
|
2022-12-28 16:48:57 -08:00
|
|
|
bool
|
2022-05-11 12:49:04 -07:00
|
|
|
Client_IsPlayer(NSClient cl)
|
2022-04-25 15:25:35 -07:00
|
|
|
{
|
|
|
|
return cl.IsPlayer();
|
2022-05-11 12:49:04 -07:00
|
|
|
}
|
2022-06-04 14:08:39 -07:00
|
|
|
|
2022-11-01 19:12:40 -07:00
|
|
|
bool
|
|
|
|
Client_InVehicle(void)
|
|
|
|
{
|
2024-04-22 22:47:54 -07:00
|
|
|
NSClientPlayer pl = (NSClientPlayer)pSeat->m_ePlayer;
|
2022-11-01 19:12:40 -07:00
|
|
|
return (pl.vehicle != world) ? true : false;
|
|
|
|
}
|
|
|
|
|
2022-06-04 14:08:39 -07:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Util_GetKeyString
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
string
|
|
|
|
Util_GetKeyString(string strBind)
|
|
|
|
{
|
2022-08-05 13:38:09 -07:00
|
|
|
float flBindKey = tokenize(findkeysforcommandex(strBind, 0));
|
2022-06-04 14:08:39 -07:00
|
|
|
string strBindTx = "";
|
2022-08-05 13:38:09 -07:00
|
|
|
float j;
|
2022-06-04 14:08:39 -07:00
|
|
|
|
2022-08-05 13:38:09 -07:00
|
|
|
for (j = 0; j < flBindKey; ++j) {
|
|
|
|
if (strBindTx != "")
|
|
|
|
strBindTx = strcat(strBindTx, ", ");
|
2022-06-04 14:08:39 -07:00
|
|
|
|
2022-08-05 13:38:09 -07:00
|
|
|
strBindTx = strcat(strBindTx, argv(j));
|
2022-06-04 14:08:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!strBindTx)
|
|
|
|
strBindTx = "UNBOUND";
|
|
|
|
|
|
|
|
return strtoupper(strBindTx);
|
|
|
|
}
|
2022-07-28 15:53:27 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
Util_IsFocused(void)
|
|
|
|
{
|
|
|
|
return g_focus;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Util_GetMaxPlayers(void)
|
|
|
|
{
|
|
|
|
return g_numplayerslots;
|
|
|
|
}
|
2023-06-15 11:40:46 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|