update steamid-stocks to handle 64-bit ids on csgo

This commit is contained in:
rtldg 2022-12-30 12:08:56 +00:00
parent 9400b7c7e3
commit 412812693f
5 changed files with 66 additions and 4 deletions

View File

@ -24,7 +24,15 @@
#endif
#define _steamid_stocks_included
#if SOURCEMOD_V_MAJOR > 1 || SOURCEMOD_V_MINOR >= 11
#else
static KeyValues kv = null;
static bool hasi64 = false;
native int Int64ToString(const int num[2], char[] str, int maxlength);
native int StringToInt64(const char[] str, int result[2], int nBase=10);
#endif
// Retrieves accountid from STEAM_X:Y:Z, [U:1:123], and 765xxxxxxxxxxxxxx
stock int SteamIDToAccountID(const char[] sInput)
@ -85,22 +93,52 @@ stock void AccountIDToSteamID3(int accountid, char[] buf, int buflen)
FormatEx(buf, buflen, "[U:1:%u]", accountid);
}
stock void SteamID64ToString(int num[2], char[] buf, int buflen)
stock void SteamID64ToString(const int num[2], char[] buf, int buflen)
{
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR >= 11
Int64ToString(num, buf, buflen);
#else
if (kv == null)
{
if (!hasi64)
hasi64 = GetFeatureStatus(FeatureType_Native, "Int64ToString") == FeatureStatus_Available;
if (hasi64)
{
Int64ToString(num, buf, buflen);
return;
}
kv = new KeyValues("fuck sourcemod");
}
kv.SetUInt64(NULL_STRING, num);
kv.GetString(NULL_STRING, buf, buflen);
#endif
}
stock int SteamID64ToAccountID(const char[] steamid64)
{
if (kv == null)
kv = new KeyValues("fuck sourcemod");
int num[2];
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR >= 11
StringToInt64(steamid64, num);
#else
if (kv == null)
{
if (!hasi64)
hasi64 = GetFeatureStatus(FeatureType_Native, "StringToInt64") == FeatureStatus_Available;
if (hasi64)
{
StringToInt64(steamid64, num);
return num[0];
}
kv = new KeyValues("fuck sourcemod");
}
kv.SetString(NULL_STRING, steamid64);
kv.GetUInt64(NULL_STRING, num);
#endif
return num[0];
}

View File

@ -129,6 +129,12 @@ public Plugin myinfo =
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR >= 11
#else
MarkNativeAsOptional("Int64ToString");
MarkNativeAsOptional("StringToInt64");
#endif
gB_Late = late;
CreateNative("Shavit_GetPlainChatrank", Native_GetPlainChatrank);

View File

@ -190,6 +190,12 @@ public Plugin myinfo =
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR >= 11
#else
MarkNativeAsOptional("Int64ToString");
MarkNativeAsOptional("StringToInt64");
#endif
new Convar("shavit_core_log_sql", "0", "Whether to log SQL queries from the timer.", 0, true, 0.0, true, 1.0);
Bhopstats_CreateNatives();

View File

@ -92,6 +92,12 @@ public Plugin myinfo =
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR >= 11
#else
MarkNativeAsOptional("Int64ToString");
MarkNativeAsOptional("StringToInt64");
#endif
RegPluginLibrary("shavit-stats");
gB_Late = late;

View File

@ -127,6 +127,12 @@ public Plugin myinfo =
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR >= 11
#else
MarkNativeAsOptional("Int64ToString");
MarkNativeAsOptional("StringToInt64");
#endif
// natives
CreateNative("Shavit_GetClientPB", Native_GetClientPB);
CreateNative("Shavit_SetClientPB", Native_SetClientPB);