From 45bb1a4c0b738487737f816767d0cb616b590112 Mon Sep 17 00:00:00 2001 From: zaCade Date: Tue, 8 Oct 2019 14:07:48 +0200 Subject: [PATCH] PlayerManager: Add planned native, STILL WIP! Wont break anything, so whatever. Just doesnt do anything. --- .../scripting/PlayerManager_Connect.sp | 28 +++++++++++++++++++ .../scripting/include/PlayerManager.inc | 17 +++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/PlayerManager/scripting/PlayerManager_Connect.sp b/PlayerManager/scripting/PlayerManager_Connect.sp index de642d10..d29f33e9 100644 --- a/PlayerManager/scripting/PlayerManager_Connect.sp +++ b/PlayerManager/scripting/PlayerManager_Connect.sp @@ -14,6 +14,9 @@ ConVar g_hCvar_BlockVoice; /* DATABASE */ Database g_hDatabase; +/* STRING */ +char g_cPlayerGUID[MAXPLAYERS + 1][40]; + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -32,6 +35,7 @@ public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int erro { CreateNative("PM_IsPlayerSteam", Native_IsPlayerSteam); CreateNative("PM_GetPlayerType", Native_GetPlayerType); + CreateNative("PM_GetPlayerGUID", Native_GetPlayerGUID); RegPluginLibrary("PlayerManager"); return APLRes_Success; @@ -351,4 +355,28 @@ public int Native_GetPlayerType(Handle hPlugin, int numParams) return !SetNativeString(2, "SteamLegit", length + 1); return !SetNativeString(2, "NoAuth", length + 1); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public int Native_GetPlayerGUID(Handle hPlugin, int numParams) +{ + int client = GetNativeCell(1); + int length = GetNativeCell(3); + + if (client < 1 || client > MaxClients) + { + return ThrowNativeError(SP_ERROR_NATIVE, "Client index %d is invalid", client); + } + else if (!IsClientConnected(client)) + { + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not connected", client); + } + else if (IsFakeClient(client)) + { + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is a bot", client); + } + + return !SetNativeString(2, g_cPlayerGUID[client], length + 1); } \ No newline at end of file diff --git a/PlayerManager/scripting/include/PlayerManager.inc b/PlayerManager/scripting/include/PlayerManager.inc index a711ee90..1970e5cd 100644 --- a/PlayerManager/scripting/include/PlayerManager.inc +++ b/PlayerManager/scripting/include/PlayerManager.inc @@ -7,9 +7,9 @@ /** * Check if clients usertype is legit. * - * @param clients The client index. + * @param client The client index. * - * @return True if valid, false otherwise. + * @return True if legit, false otherwise. * @error Invalid client index, not connected or fake client. */ native bool PM_IsPlayerSteam(int client); @@ -17,7 +17,7 @@ native bool PM_IsPlayerSteam(int client); /** * Retrieve clients usertype. * - * @param clients The client index. + * @param client The client index. * @param type The buffer to write to. * @param maxlength The maximum buffer length. * @@ -26,6 +26,16 @@ native bool PM_IsPlayerSteam(int client); */ native bool PM_GetPlayerType(int client, char[] type, int maxlength); +/** + * Retrieve clients globally unique identifier (GUID). + * + * @param client The client index. + * + * @return GUID on success, -1 otherwise. + * @error Invalid client index, not connected or fake client. + */ +native int PM_GetPlayerGUID(int client); + public SharedPlugin __pl_PlayerManager = { @@ -44,5 +54,6 @@ public SharedPlugin __pl_PlayerManager = { MarkNativeAsOptional("PM_IsPlayerSteam"); MarkNativeAsOptional("PM_GetPlayerType"); + MarkNativeAsOptional("PM_GetPlayerGUID"); } #endif