PHP Code:
/* Formatright © 2011, ConnorMcLeod
Admins & VIPs Tags is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Admins Tag; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#define FLAG_ADMIN_ADMIN ADMIN_BAN // obligatoirement un flag que les VIPs n'ont pas
#define FLAG_ADMIN_VIP ADMIN_LEVEL_B
#include <amxmodx>
#define VERSION "0.0.1"
#define MAX_NAME_LENGTH 32
new g_pCvarAdminTag, g_pCvarVipTag, g_pCvarVipPlace, g_pCvarAdminPlace
public plugin_init()
{
register_plugin("Admins & VIPs Tags", VERSION, "ConnorMcLeod")
g_pCvarAdminTag = register_cvar("amx_admin_tag", "[ADMIN]")
g_pCvarVipTag = register_cvar("amx_vip_tag", "[VIP]")
g_pCvarVipPlace = register_cvar("amx_vip_tag_potision", "0") // 0 left, 1 right
g_pCvarAdminPlace = register_cvar("amx_admin_tag_potision", "0")
}
public client_authorized( id )
{
new iAdminType = get_user_admin(id)
if( !iAdminType )
{
return
}
new szName[MAX_NAME_LENGTH]
new iNameLen = get_user_name(id, szName, charsmax(szName))
CheckUserName(id, szName, iNameLen, iAdminType)
}
public client_infochanged(id)
{
if( is_user_connected(id) )
{
new iAdminType = get_user_admin(id)
if( !iAdminType )
{
return
}
new szOldName[MAX_NAME_LENGTH],szNewName[MAX_NAME_LENGTH]
get_user_name(id, szOldName, charsmax(szOldName))
new iNameLen = get_user_info(id, "name", szNewName, charsmax(szNewName))
if( !equal(szOldName, szNewName) )
{
CheckUserName(id, szNewName, iNameLen, iAdminType)
}
}
}
CheckUserName(const id, szName[MAX_NAME_LENGTH], const iNameLen, const iAdminType)
{
new szTag[32]
new iTagLen = get_pcvar_string(iAdminType == FLAG_ADMIN_VIP ? g_pCvarVipTag : g_pCvarAdminTag, szTag, charsmax(szTag))
if( containi(szName, szTag) != -1 )
{
return
}
if( get_pcvar_num(iAdminType == FLAG_ADMIN_VIP ? g_pCvarVipPlace : g_pCvarAdminPlace) )
{
if( MAX_NAME_LENGTH - iNameLen > iTagLen )
{
add(szName, charsmax(szName), szTag)
}
else
{
formatex(szName[MAX_NAME_LENGTH-iTagLen-1], iTagLen, szTag)
}
}
else
{
format(szName, charsmax(szName), "%s %s", szTag, szName)
}
set_user_info(id, "name", szName)
}
get_user_admin(id)
{
new __flags=get_user_flags(id)
if( __flags>0 && !(__flags&ADMIN_USER) )
{
if( __flags & FLAG_ADMIN_ADMIN )
{
return FLAG_ADMIN_ADMIN
}
else if( __flags & FLAG_ADMIN_VIP )
{
return FLAG_ADMIN_VIP
}
}
return 0
}