Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
more natives
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtko committed Mar 31, 2018
1 parent 4b35193 commit 8700f3c
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.vscode/
.vscode/

addons/sourcemod/scripting/surftimer-api.sp
addons/sourcemod/scripting/surftimer-api.smx
96 changes: 96 additions & 0 deletions addons/sourcemod/scripting/SurfTimer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
50 changes: 50 additions & 0 deletions addons/sourcemod/scripting/include/SurfTimer.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Binary file modified addons/sourcemod/scripting/surftimer.smx
Binary file not shown.
5 changes: 1 addition & 4 deletions addons/sourcemod/scripting/surftimer/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8700f3c

Please sign in to comment.