Merge pull request #313 from alliedmodders/set-client-name

Add SetClientName native.
This commit is contained in:
Nicholas Hastings
2015-04-01 22:29:44 -04:00
24 changed files with 276 additions and 28 deletions
+9
View File
@@ -332,6 +332,15 @@ native ActivateEntity(entity);
*/
native SetClientInfo(client, const String:key[], const String:value[]);
/**
* Changes a client's name.
*
* @param client Player's index.
* @param name New name.
* @error Invalid client index, or client not connected.
*/
native void SetClientName(int client, const char[] name);
/**
* Gives ammo of a certain type to a player.
* This natives obeys the maximum amount of ammo a player can carry per ammo type.
-5
View File
@@ -50,9 +50,6 @@ public Plugin:myinfo =
TopMenu hTopMenu;
/* Used to get the SDK / Engine version. */
/* This is used in sm_rename and sm_changeteam */
new EngineVersion:g_ModVersion = Engine_Unknown;
#include "playercommands/slay.sp"
#include "playercommands/slap.sp"
#include "playercommands/rename.sp"
@@ -65,8 +62,6 @@ public OnPluginStart()
RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
RegAdminCmd("sm_rename", Command_Rename, ADMFLAG_SLAY, "sm_rename <#userid|name>");
g_ModVersion = GetEngineVersion();
/* Account for late loading */
TopMenu topmenu;
+1 -15
View File
@@ -37,22 +37,8 @@ PerformRename(client, target)
{
LogAction(client, target, "\"%L\" renamed \"%L\" to \"%s\")", client, target, g_NewName[target]);
/* Used on OB / L4D engine */
if (g_ModVersion != Engine_SourceSDK2006)
{
SetClientInfo(target, "name", g_NewName[target]);
}
else /* Used on CSS and EP1 / older engine */
{
if (!IsPlayerAlive(target)) /* Lets tell them about the player renamed on the next round since they're dead. */
{
decl String:m_TargetName[MAX_NAME_LENGTH];
SetClientName(target, g_NewName[target]);
GetClientName(target, m_TargetName, sizeof(m_TargetName));
ReplyToCommand(client, "[SM] %t", "Dead Player Rename", m_TargetName);
}
ClientCommand(target, "name %s", g_NewName[target]);
}
g_NewName[target][0] = '\0';
}