PlayerManager: Add planned native, STILL WIP!

Wont break anything, so whatever. Just doesnt do anything.
This commit is contained in:
zaCade 2019-10-08 14:07:48 +02:00
parent db6d227643
commit 45bb1a4c0b
2 changed files with 42 additions and 3 deletions

View File

@ -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);
}

View File

@ -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