I'm having troble getting it to work properly.
It's supposed to announce when the admin comes online and before that change the nick of the admin / freeslot.
Sorry for my bad english.
Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Admin Connect"
#define VERSION "0.8"
#define AUTHOR "Sleepwalker"
new g_iMsgSayText;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
g_iMsgSayText = get_user_msgid("SayText");
}
public client_authorized(id)
{
new iPlayers[32], iNum, i
get_players(iPlayers, iNum)
for(i = 0; i <= iNum; i++)
{
new x = iPlayers[i]
if (!is_user_connected(x) || is_user_bot(x) || is_user_hltv(x)) continue;
if (get_user_flags(x) != ADMIN_USER) {
new szAuthID[33], szUserName[33]
get_user_authid(x , szAuthID, 32)
get_user_name(x, szUserName, 32)
if (get_user_flags(x) && ADMIN_ADMIN) {
set_user_info(id,"name","%s - Admin",szUserName)
}else{
set_user_info(id,"name","%s - Freeslot",szUserName)
}
}else{
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
public client_putinserver(id){
new iPlayers2[32], iNum2, i2
get_players(iPlayers2, iNum2)
for(i2 = 0; i2 <= iNum2; i2++)
{
new x2 = iPlayers2[i2]
if (!is_user_connected(x2) || is_user_bot(x2) || is_user_hltv(x2)) continue;
if (get_user_flags(x2) == ADMIN_USER) {
new szMessage[164]
new szAuthID2[33], szUserName2[33]
get_user_authid(x2 , szAuthID2 , 32)
get_user_name(x2, szUserName2, 32)
format(szMessage, 163, "^x04%s connected", szUserName2 , szAuthID2)
message_begin( MSG_ONE, g_iMsgSayText, {0,0,0}, x2 )
write_byte ( x2 )
write_string( szMessage )
message_end ()
}else{
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
public client_infochanged(id){
new newname[32],oldname[32]
get_user_info(id,"name",newname,31)
get_user_name(id,oldname,31)
if (!equal(newname,oldname)){ // make sure name was changed
if (get_user_flags(id) != ADMIN_USER) {
if (get_user_flags(id) && ADMIN_ADMIN) {
set_user_info(id,"name","%s - TOO.Admin",newname)
client_print(id,print_chat,"Your name has been changed to '%s - Admin'",newname)
}else{
set_user_info(id,"name","%s - TOO.Freeslot",newname)
client_print(id,print_chat,"Your name has been changed to '%s - Freeslot'",newname)
}
}else{
client_print(id,print_chat,"Your name has been changed to '%s'",newname)
}
}
}