Raised This Month: $ Target: $400
 0% 

Admin Only print_chat help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
noonoo
Senior Member
Join Date: Mar 2006
Location: London - UK
Old 05-28-2006 , 06:19   Admin Only print_chat help
Reply With Quote #1

How would i make the code below only visable to admins instead of all:
Code:
case 1: 
				{
					client_print(0,print_chat,"text for admin in here",command)
					server_print("text for admin in here",command)
				}
Many thanks in advance
noonoo is offline
unnamed :)
Member
Join Date: Apr 2006
Old 05-28-2006 , 07:05  
Reply With Quote #2

Code:
case 1: {     if(is_user_admin(id) == 1) {         client_print(id,print_chat,"text for admin",command)         server_print("text for admin",command)     } }
unnamed :) is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-28-2006 , 09:41  
Reply With Quote #3

It's better to check like this:

Code:
case 1: {     if(is_user_admin(id)) {         client_print(id,print_chat,"text for admin %s",command)         server_print("text for admin %s",command)     } }

I also noticed you added a parameter to client_print and server_print without %s.

And also, the above example probably doesn't cover using it on more than one person. If you want to use it on all admins in the server, you must use get_players and then cycle through each player, checking if they each have admin.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-28-2006 , 10:49  
Reply With Quote #4

Like so:

Code:
        new players[32];         get_players(players,g_num,"c")         for(new GABEN = 0; GABEN < g_num; GABEN++)         {             new GABENadmin = players[GABEN]             if(is_user_admin(GABENadmin))             {                 client_print(GABENadmin,print_chat,"text for admin %s",command)                         }         }
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-28-2006 , 10:55  
Reply With Quote #5

Quote:
Originally Posted by SweatyBanana
Like so:

Code:
        new players[32];         get_players(players,g_num,"c")         for(new GABEN = 0; GABEN < g_num; GABEN++)         {             new GABENadmin = players[GABEN]             if(is_user_admin(GABENadmin))             {                 client_print(id,print_chat,"text for admin %s",command)                 server_print("text for admin %s",command)                           }         }
Stop using "GABEN" as variable names. It's not funny, and it makes it harder to read.

There were also a couple of errors in that script. Here's a fixed and more readable version:

Code:
new iPlayers[32],iPlayersnum,iPlayer get_players(iPlayers,iPlayersnum,"c") for(new iCount = 0;iCount < iPlayersnum;iCount++) {     iPlayer = iPlayers[iCount]     if(is_user_admin(iPlayer))     {         client_print(iPlayer,print_chat,"text for admin %s",command)         server_print("text for admin %s",command)                   } }
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
noonoo
Senior Member
Join Date: Mar 2006
Location: London - UK
Old 05-28-2006 , 11:12  
Reply With Quote #6

Hi guys many thanks for the help so far, from what i have read the code below will only show to the admin that did the command.

Code:
case 1: 
				{
             if(is_user_admin(id)) {
					client_print(id,print_chat,"text for admin ^"%s^ in here" has been used on you all",command)
				}
      }
				case 2: 
				{
             if(is_user_admin(id)) {
					client_print(id,print_chat,"text for admin ^"%s^ in here" has been used on everybody",admin,command)
				}
      }
I dropped the server_print as it was not needed really, also it not needed to show all admins infact maybe better that it does not.
Sorry to ask so many questions but its all new to me, trying to learn as much as poss as quickly as poss. Trying to run before i can walk

Many many thanks again guys
noonoo is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-28-2006 , 11:26  
Reply With Quote #7

There are so many things wrong with that script. And I'm sure its not going to work the way you wanted to if you fixed all the errors.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
noonoo
Senior Member
Join Date: Mar 2006
Location: London - UK
Old 05-28-2006 , 13:12  
Reply With Quote #8

I did the changes what i posted above and it seems to have worked ok, only i could see the text (admin) and no other players could.

What would you recommend instead Suicide3 for me to do to make it better or more code friendly.

Thanks for any advice in advance
noonoo is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-28-2006 , 13:53  
Reply With Quote #9

Here is your exact code color coded.....use small tags instead of code tags.
Do you see where you screwed up?
Code:
case 1:                 {              if(is_user_admin(id)) {                     client_print(id,print_chat,"text for admin ^"%s^ in here" has been used on you all",command)                 }       }                 case 2:                 {              if(is_user_admin(id)) {                     client_print(id,print_chat,"text for admin ^"%s^ in here" has been used on everybody",admin,command)                 }       }
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
noonoo
Senior Member
Join Date: Mar 2006
Location: London - UK
Old 05-28-2006 , 17:30  
Reply With Quote #10

The more i look at the code the more of a code noob i feel, i have no idea whats wrong. Thats why i posted for help as i have such a basic idea of what to do, any help would be great m8 always happy to learn
noonoo 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 05:47.


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