diff --git a/.gitignore b/.gitignore index dbe9c82..e44edc3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -.vscode/ \ No newline at end of file +.vscode/ + +addons/sourcemod/scripting/surftimer-api.sp +addons/sourcemod/scripting/surftimer-api.smx \ No newline at end of file diff --git a/addons/sourcemod/scripting/SurfTimer.sp b/addons/sourcemod/scripting/SurfTimer.sp index e064877..2ef1fdb 100644 --- a/addons/sourcemod/scripting/SurfTimer.sp +++ b/addons/sourcemod/scripting/SurfTimer.sp @@ -2841,6 +2841,96 @@ public int Native_GetPlayerPoints(Handle plugin, int numParams) return -1; } +public int Native_GetPlayerSkillgroup(Handle plugin, int numParams) +{ + int client = GetNativeCell(1); + char str[256]; + GetNativeString(2, str, 256); + if (IsValidClient(client) && !IsFakeClient(client)) + { + Format(str, sizeof(str), g_pr_chat_coloredrank[client]); + SetNativeString(2, str, 256, true); + } + else + { + Format(str, sizeof(str), "Unranked"); + SetNativeString(2, str, 256, true); + } +} + +public int Native_GetPlayerNameColored(Handle plugin, int numParams) +{ + int client = GetNativeCell(1); + char str[256]; + GetNativeString(2, str, 256); + if (IsValidClient(client) && !IsFakeClient(client)) + { + GetClientName(client, str, sizeof(str)); + Format(str, sizeof(str), "%s%s", g_pr_namecolour[client], str); + SetNativeString(2, str, 256, true); + } + else + { + Format(str, sizeof(str), "invalid"); + SetNativeString(2, str, 256, true); + } +} + +public int Native_GetMapData(Handle plugin, int numParams) +{ + char name[MAX_NAME_LENGTH], time[64]; + GetNativeString(1, name, MAX_NAME_LENGTH); + GetNativeString(2, time, 64); + + Format(name, sizeof(name), g_szRecordPlayer); + Format(time, sizeof(time), g_szRecordMapTime); + SetNativeString(1, name, sizeof(name), true); + SetNativeString(2, time, sizeof(time), true); + + return g_MapTimesCount; +} + +public int Native_GetPlayerData(Handle plugin, int numParams) +{ + int client = GetNativeCell(1); + int rank = 99999; + if (IsValidClient(client) && !IsFakeClient(client)) + { + char szTime[64], szCountry[16]; + + GetNativeString(1, szTime, 64); + rank = GetNativeCell(2); + GetNativeString(3, szCountry, 16); + + if (g_fPersonalRecord[client] > 0.0) + Format(szTime, 64, "%s", g_szPersonalRecord[client]); + else + Format(szTime, 64, "N/A"); + + Format(szCountry, sizeof(szCountry), g_szCountryCode[client]); + + rank = g_MapRank[client]; + + SetNativeString(2, szTime, sizeof(szTime), true); + SetNativeString(4, szCountry, sizeof(szCountry), true); + } + + return rank; +} + +public int Native_GetMapTier(Handle plugin, int numParams) +{ + return g_iMapTier; +} + +public int Native_GetMapStages(Handle plugin, int numParams) +{ + int stages = 0; + if (g_bhasStages) + stages = g_mapZonesTypeCount[0][3] + 1; + return stages; +} + public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { RegPluginLibrary("surftimer"); @@ -2851,6 +2941,12 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max CreateNative("surftimer_GetCurrentTime", Native_GetCurrentTime); CreateNative("surftimer_GetPlayerRank", Native_GetPlayerRank); CreateNative("surftimer_GetPlayerPoints", Native_GetPlayerPoints); + CreateNative("surftimer_GetPlayerSkillgroup", Native_GetPlayerSkillgroup); + CreateNative("surftimer_GetPlayerNameColored", Native_GetPlayerNameColored); + CreateNative("surftimer_GetMapData", Native_GetMapData); + CreateNative("surftimer_GetPlayerData", Native_GetPlayerData); + CreateNative("surftimer_GetMapTier", Native_GetMapTier); + CreateNative("surftimer_GetMapStages", Native_GetMapStages); CreateNative("surftimer_SafeTeleport", Native_SafeTeleport); CreateNative("surftimer_IsClientVip", Native_IsClientVip); MarkNativeAsOptional("Store_GetClientCredits"); diff --git a/addons/sourcemod/scripting/include/SurfTimer.inc b/addons/sourcemod/scripting/include/SurfTimer.inc index ccfa131..aca8cc5 100644 --- a/addons/sourcemod/scripting/include/SurfTimer.inc +++ b/addons/sourcemod/scripting/include/SurfTimer.inc @@ -69,6 +69,56 @@ native surftimer_GetPlayerRank(client); */ native surftimer_GetPlayerPoints(client); +/** + * Gets the skillgroup of a client + * + * @param client Client's id + * @param str String to convert + * @return Skillgroup as a string / Unranked on failure + */ +native surftimer_GetPlayerSkillgroup(client, String:str[]); + +/** + * Gets current map tier + * @return Current map tier + */ +native surftimer_GetMapTier(); + +/** + * Gets amount of stages on current map + * @return amount of stages on current map / 0 if linear + */ +native surftimer_GetMapStages(); + +/** + * Gets a clients name with colour in string + * + * @param client Client's id + * @param str String to convert + * @return Players name with color as a string / invalid on failure + */ +native surftimer_GetPlayerNameColored(client, String:str[]); + +/** + * Gets current map wr holder and time + * + * @param name String to convert for wr holder name + * @param time String to convert for wr holder time + * @return total players finished on current map + */ +native surftimer_GetMapData(String:name[], String:time[]); + +/** + * Gets client data + * + * @param client Client's id + * @param time String to convert for players map time + * @param rank int to convert to players map rank + * @param country String to convert for players country + * @return Two strings with wr holder name and time + */ +native surftimer_GetPlayerData(client, String:time[], rank, String:country[]); + /** * Safely teleports the client. Does not trigger end touches * and sets client location correctly. diff --git a/addons/sourcemod/scripting/surftimer.smx b/addons/sourcemod/scripting/surftimer.smx index d11207e..84f77f0 100644 Binary files a/addons/sourcemod/scripting/surftimer.smx and b/addons/sourcemod/scripting/surftimer.smx differ diff --git a/addons/sourcemod/scripting/surftimer/commands.sp b/addons/sourcemod/scripting/surftimer/commands.sp index 63950fa..a25908b 100644 --- a/addons/sourcemod/scripting/surftimer/commands.sp +++ b/addons/sourcemod/scripting/surftimer/commands.sp @@ -285,10 +285,7 @@ void CreateCommandListeners() public Action sm_test(int client, int args) { - if (g_bInBonus[client]) - CPrintToChatAll("true - %d", g_iInBonus[client]); - else - CPrintToChatAll("false"); + CPrintToChatAll("%d", g_iMapTier); return Plugin_Handled; }