Permalink
Browse files

Add TTT_GetRoundTime

  • Loading branch information...
Bara committed May 21, 2018
1 parent 049aaa7 commit aa1f693798f15dbabf0fc78ee648212215d426c2
Showing with 35 additions and 0 deletions.
  1. +7 −0 addons/sourcemod/scripting/include/ttt.inc
  2. +28 −0 addons/sourcemod/scripting/ttt/core/natives.sp
@@ -310,6 +310,13 @@ native int TTT_SetRoundSlays(int client, int rounds, bool force);
*/
native void TTT_ClientOpenRules(int client);
/*
* Returns the time of a active rounds (-1 for inactive round/failed to start)
*
* @param type Which type is needed? (0 - Time, 1 - Minutes, 2 - Seconds)
*/
native void TTT_GetRoundTime(int type);
stock void TTT_GetRoleNameByID(int role, char[] name, int length = ROLE_LENGTH)
{
if (role == TTT_TEAM_INNOCENT)
@@ -40,6 +40,7 @@ void InitNatives()
CreateNative("TTT_SetRoundSlays", Native_SetRoundSlays);
CreateNative("TTT_IsPlayerAlive", Native_IsPlayerAlive);
CreateNative("TTT_ClientOpenRules", Native_ClientOpenRules);
CreateNative("TTT_GetRoundTime", Native_GetRoundTime);
}
public int Native_IsRoundActive(Handle plugin, int numParams)
@@ -403,3 +404,30 @@ public int Native_ClientOpenRules(Handle plugin, int numParams)
return -1;
}
public int Native_GetRoundTime(Handle plugin, int numParams)
{
if (g_iTeamSelectTime > 0)
{
int type = GetNativeCell(1);
int iTime = GetTime() - g_iTeamSelectTime;
if (type == 0)
{
// Time
return iTime;
}
else if (type == 1)
{
// Minutes
return ((iTime / 60) % 60);
}
else if (type == 2)
{
// Seconds
return (iTime % 60);
}
}
return -1;
}

0 comments on commit aa1f693

Please sign in to comment.