Raised This Month: $32 Target: $400
 8% 

Getting admin name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 04-30-2020 , 10:11   Getting admin name
Reply With Quote #1

Hello everyone...

Do someone can help me? i need to get the admin name.

P.S: but without using => public VoteCounter(id)
Code:
public VoteCounter()
{
	if(BeginCounter > 0)
	{
		new String[32];
		num_to_str(BeginCounter, String, 2);
		
		if(get_pcvar_num(Cvar_CountSound) == 1)
		{
			new CountSound[32];
			num_to_word(BeginCounter, CountSound, 31);
			
			if(get_pcvar_num(Cvar_VoteSound) == 1)
				client_cmd(0, "spk ^"fvox/%s^"", CountSound);
		}
		
		set_hudmessage(R, G, B, -1.0, 0.20, 0, 0.1, CHUD);
		
		if(VoteMod == 4)
		{
			ShowSyncHudMsg(0, sHudObj, "%L", Lang, "VOTE4", String);
		}
		else if(VoteMod == 3)
		{
			ShowSyncHudMsg(0, sHudObj, "%L", Lang, "VOTE3", String);
		}
		else if(VoteMod == 2)
		{
			ShowSyncHudMsg(0, sHudObj, "[ADMIN NAME HERE] Starting Map Voting!^nPlease wait %s seconds...", String);
		}
		else if(VoteMod == 1)
		{
			ShowSyncHudMsg(0, sHudObj, "%L", Lang, "VOTE1", String);
		}
		
		BeginCounter--;
		set_task(1.0, "VoteCounter", MapID+8123);
	}
	else
	{
		if(NeedRV)
		{
			StartRevote();
		}
		else
		{
			StartMapChooser();
		}
	}
}
Thanks in advance
PredatorBlock is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 04-30-2020 , 10:19   Re: Getting admin name
Reply With Quote #2

If you have only one admin, use get_user_name with client_putinserver and save it in a global variable.
__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 04-30-2020 at 10:20.
+ARUKARI- is offline
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 04-30-2020 , 12:29   Re: Getting admin name
Reply With Quote #3

Thank you for reply.

But i have more than 1 admin... do you know how to make it work with multiple admins?

Last edited by PredatorBlock; 04-30-2020 at 13:15.
PredatorBlock is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-30-2020 , 14:17   Re: Getting admin name
Reply With Quote #4

Code:
new g_szName[33][32] public client_putinserver(id) {     get_user_name(id, g_szName[id], charsmax(g_szName[])) } client_print(id, print_chat, "Your name is %s", g_szName[id])

If you're using AMXX 1.9, this is not needed.

Bear in mind admins can change their name during the game, so you should handle that too.
__________________

Last edited by OciXCrom; 05-01-2020 at 07:24.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 04-30-2020 , 18:12   Re: Getting admin name
Reply With Quote #5

@OciXCrom
like this?
PHP Code:
new g_szName[33][MAX_NAME_LENGTH
and, How to implement for 1.9?
__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 04-30-2020 at 19:12.
+ARUKARI- is offline
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 04-30-2020 , 19:28   Re: Getting admin name
Reply With Quote #6

Quote:
Originally Posted by OciXCrom View Post
Code:
new g_szName[33] public client_putinserver(id) {     get_user_name(id, g_szName[id], charsmax(g_szName[])) } client_print(id, print_chat, "Your name is %s", g_szName[id])

If you're using AMXX 1.9, this is not needed.

Bear in mind admins can change their name during the game, so you should handle that too.
Thanks for reply.
I am using AMXX 1.10


Code:
new rangName[33], admName[33]; public client_putinserver(id) {     get_user_name( id, admName[id], charsmax(admName[]) );         if ( (get_user_flags(id) & ADMIN) )     {         formatex(rangName, 33, "Admin");     }         else if ( (get_user_flags(id) & MODERATOR) )     {         formatex(rangName, 33, "Moderator");     }         else if ( (get_user_flags(id) & HELPER) )     {         formatex(rangName, 33, "Helper");     } } public VoteCounter() {     ShowSyncHudMsg(0, sHudObj, "[%s - %s] Starting Map Voting!", rangName, admName[id]); //<=i got error: undefined symbol id }


And how i can handle if admins change their name? can you help me?

Thank you.

Last edited by PredatorBlock; 04-30-2020 at 19:50.
PredatorBlock is offline
thEsp
BANNED
Join Date: Aug 2017
Old 04-30-2020 , 20:46   Re: Getting admin name
Reply With Quote #7

Please, don't learn AMXX by rote. Learning by rote is for example learning what 1+2 counts instead of learning how to count.

There is no variable named "id" and therefore you get an error. What you would do however, is loop through all players and send the message individually. As for name change handling, you have to take a look at client_infochanged forward.
thEsp is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 04-30-2020 , 20:54   Re: Getting admin name
Reply With Quote #8

So, I said ”If you have only one admin".

If there are multiple admin, appropriate logic is required.
But your request is not 100% written so it cannot be answered perfectly.

We are not esper.
__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 04-30-2020 at 20:58.
+ARUKARI- is offline
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 04-30-2020 , 21:53   Re: Getting admin name
Reply With Quote #9

@thEsp

Thanks for answer... it's to hard for me so i quick...

I appreciate for help guys thank you.
PredatorBlock is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-01-2020 , 07:26   Re: Getting admin name
Reply With Quote #10

Since you're using 1.10, you don't need to use "get_user_name" in this case.
Instead of using %s in the string, use %n. This stands for client name. Then, instead of passing the variable that holds the name, you would just pass the client's id.

Code:
client_print(id, print_chat, "Your name is %n", id)
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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:11.


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