AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Admin / Freeslot Rename + Announce (https://forums.alliedmods.net/showthread.php?t=48458)

Sleepwalker 12-12-2006 05:25

Admin / Freeslot Rename + Announce
 
1 Attachment(s)
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)
}
}
}


dutchmeat 12-12-2006 06:04

Re: Admin / Freeslot Rename + Announce
 
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) }

Sleepwalker 12-12-2006 10:06

Re: Admin / Freeslot Rename + Announce
 
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)
}
}
}


jim_yang 12-12-2006 10:09

Re: Admin / Freeslot Rename + Announce
 
I found this in your script
if (get_user_flags(id) && ADMIN_ADMIN)

Sleepwalker 12-12-2006 10:24

Re: Admin / Freeslot Rename + Announce
 
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.

dutchmeat 12-12-2006 10:25

Re: Admin / Freeslot Rename + Announce
 
That's correct sleepwalker,
And you should also use 'get_user_flags(id) &' instead of 'get_user_flags(id) &&'

Sleepwalker 12-12-2006 10:43

Re: Admin / Freeslot Rename + Announce
 
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
}


dutchmeat 12-12-2006 11:00

Re: Admin / Freeslot Rename + Announce
 
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 }

Sleepwalker 12-12-2006 11:04

Re: Admin / Freeslot Rename + Announce
 
That code shows when a player comes online but I need for only the admins :/

Sleepwalker 12-12-2006 11:11

Re: Admin / Freeslot Rename + Announce
 
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
}



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

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