AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Admin Only print_chat help (https://forums.alliedmods.net/showthread.php?t=29028)

noonoo 05-28-2006 06:19

Admin Only print_chat help
 
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 :D

unnamed :) 05-28-2006 07:05

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

Hawk552 05-28-2006 09:41

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.

SweatyBanana 05-28-2006 10:49

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)                         }         }

Hawk552 05-28-2006 10:55

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)                   } }

noonoo 05-28-2006 11:12

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 :D :D :D

Many many thanks again guys :D

Xanimos 05-28-2006 11:26

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.

noonoo 05-28-2006 13:12

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 :D

Xanimos 05-28-2006 13:53

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)                 }       }

noonoo 05-28-2006 17:30

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 :D :D :D


All times are GMT -4. The time now is 16:32.

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