Raised This Month: $ Target: $400
 0% 

Admin / Freeslot Rename + Announce


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sleepwalker
Member
Join Date: Dec 2006
Old 12-12-2006 , 05:25   Admin / Freeslot Rename + Announce
Reply With Quote #1

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)
}
}
}
Attached Files
File Type: sma Get Plugin or Get Source (connect_announce_swp.sma - 242 views - 2.2 KB)
Sleepwalker is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-12-2006 , 06:04   Re: Admin / Freeslot Rename + Announce
Reply With Quote #2

You should use 'id' instead of 'x2'

Code:
public client_putinserver(id){ new szUserName[32] get_user_name( id2, szUserName, 31 ) log_amx("This client has joined the game: %s",szUserName) }
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
Sleepwalker
Member
Join Date: Dec 2006
Old 12-12-2006 , 10:06   Re: Admin / Freeslot Rename + Announce
Reply With Quote #3

Is this better?
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(id) || is_user_bot(id) || is_user_hltv(id)) continue;
if (get_user_flags(id) != ADMIN_USER) {
new szAuthID[33], szUserName[33]
get_user_authid(id , szAuthID, 32)
get_user_name(id, szUserName, 32)
if (get_user_flags(id) && ADMIN_ADMIN) {
client_cmd(id, "setinfo name '^"%s^" - TOO.Admin'", szUserName)
}else{
client_cmd(id, "setinfo name '^"%s^" - TOO.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(id) || is_user_bot(id) || is_user_hltv(id)) continue;
if (get_user_flags(id) == ADMIN_USER) {
new szMessage[164]
new szAuthID2[33], szUserName2[33]
get_user_authid(id , szAuthID2 , 32)
get_user_name(id, 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) {
client_cmd(id, "setinfo name '^"%s^" - TOO.Admin'", newname)
client_print(id,print_chat,"Your name has been changed to '%s - TOO.Admin'",newname)
}else{
client_cmd(id, "setinfo name '^"%s^" - TOO.Freeslot'", newname)
client_print(id,print_chat,"Your name has been changed to '%s - TOO.Freeslot'",newname)
}
}else{
client_print(id,print_chat,"Your name has been changed to '%s'",newname)
}
}
}
Sleepwalker is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 12-12-2006 , 10:09   Re: Admin / Freeslot Rename + Announce
Reply With Quote #4

I found this in your script
if (get_user_flags(id) && ADMIN_ADMIN)
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Sleepwalker
Member
Join Date: Dec 2006
Old 12-12-2006 , 10:24   Re: Admin / Freeslot Rename + Announce
Reply With Quote #5

I'm new to this scripting so.
I have been trying to an admin:

<nick> - Admin

and to one with only freeslot

<nick> - Freeslot

and then announce when the person comes online.
I don't know i the code is right or wrong but I have been trying.


That you found is what I tought the bit that sorted out the one's that where not admins.
But as I said that im new to this and I don't know if it's the right code.
Sleepwalker is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-12-2006 , 10:25   Re: Admin / Freeslot Rename + Announce
Reply With Quote #6

That's correct sleepwalker,
And you should also use 'get_user_flags(id) &' instead of 'get_user_flags(id) &&'
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
Sleepwalker
Member
Join Date: Dec 2006
Old 12-12-2006 , 10:43   Re: Admin / Freeslot Rename + Announce
Reply With Quote #7

The Code Now looks like this.
Two problems left.

1. it's changeing the name of the admin 2 times.
first to: <name> - Admin
then to: <name> - Admin - Admin

2. It dosn't write out when a person comes online.

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)
{
if (get_user_flags(id) != ADMIN_USER) {
new szAuthID[33], szUserName[33]
get_user_authid(id , szAuthID, 32)
get_user_name(id, szUserName, 32)
if (get_user_flags(id) & ADMIN_ADMIN) {
client_cmd(id, "setinfo name ^"%s - TOO.Admin^"", szUserName)
}else{
client_cmd(id, "setinfo name ^"%s - TOO.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(id) != 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) {
client_cmd(id, "setinfo name ^"%s - TOO.Admin^"", newname)
client_print(id,print_chat,"Your name has been changed to '%s - TOO.Admin'",newname)
}else{
client_cmd(id, "setinfo name ^"%s - TOO.Freeslot^"", newname)
client_print(id,print_chat,"Your name has been changed to '%s - TOO.Freeslot'",newname)
}
}else{
client_print(id,print_chat,"Your name has been changed to '%s'",newname)
}
}
return PLUGIN_CONTINUE
}
Sleepwalker is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-12-2006 , 11:00   Re: Admin / Freeslot Rename + Announce
Reply With Quote #8

First debug the connect message:

Code:
public client_putinserver(id){ if (!is_user_connected(id) || is_user_bot(id) || is_user_hltv(id))    continue; new szMessage[164] new szAuthID2[33], szUserName2[33] get_user_authid(id , szAuthID2 , 32) get_user_name(id, szUserName2, 32) format(szMessage, 163, "^x04%s connected", szUserName2 , szAuthID2) for(i = 0; i <= iNum; i++) { new x = iPlayers[i]; message_begin( MSG_ONE, g_iMsgSayText, {0,0,0}, x ) write_byte (x) write_string( szMessage ) message_end () } return PLUGIN_CONTINUE }
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
Sleepwalker
Member
Join Date: Dec 2006
Old 12-12-2006 , 11:04   Re: Admin / Freeslot Rename + Announce
Reply With Quote #9

That code shows when a player comes online but I need for only the admins :/
Sleepwalker is offline
Sleepwalker
Member
Join Date: Dec 2006
Old 12-12-2006 , 11:11   Re: Admin / Freeslot Rename + Announce
Reply With Quote #10

Plus it must be:
if (!is_user_connected(id) || is_user_bot(id) || is_user_hltv(id)) continue;
cant be outside the for function

Code:
public client_putinserver(id){
new szMessage[164]
new szAuthID[33], szUserName[33]
get_user_authid(id , szAuthID , 32)
get_user_name(id, szUserName, 32)
format(szMessage, 163, "^x04%s connected", szUserName , szAuthID)
new iPlayers[32], iNum, i
get_players(iPlayers, iNum)
for(i = 0; i <= iNum; i++)
{
if (!is_user_connected(id) || is_user_bot(id) || is_user_hltv(id)) continue;
new x = iPlayers[i]
message_begin( MSG_ONE, g_iMsgSayText, {0,0,0}, x )
write_byte ( x )
write_string( szMessage )
message_end ()
}
return PLUGIN_CONTINUE
}

Last edited by Sleepwalker; 12-12-2006 at 11:11. Reason: Wrong Parameter
Sleepwalker is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode