AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to print only one time (https://forums.alliedmods.net/showthread.php?t=271089)

indraraj striker 09-05-2015 01:13

how to print only one time
 
1 Attachment(s)
how to do ?
Loop all players to check flag but print only one time
Problem :
now its printing
NO Admins Online
NO Admins Online
NO Admins Online
NO Admins Online
depending upon online players

PHP Code:

#include <amxmodx>

public plugin_init() {
register_clcmd("say /test","test");
}

public 
test()
{
new 
players[32], inumtempid;
get_players(playersinum);

for(new 
ii<inumi++)
        {        
            
tempid players[i];

            if(!(
get_user_flags(tempid) & ADMIN_KICK))
{
client_print(0,print_chat,"NO Admins Online");
}
}



Hartmann 09-05-2015 06:52

Re: how to print only one time
 
Try with 0 --> tempid

indraraj striker 09-05-2015 07:44

Re: how to print only one time
 
Yup tempid is working for chat but how to do for menu
Any idea for menu ?
PHP Code:

loop through all players as above code 
formatex
(msgcharsmax(msg), "\yNo Admins Online")
menu_additem(menumsg); 


fysiks 09-05-2015 11:46

Re: how to print only one time
 
To only print once, you should have a boolean that you set to true when you find an admin and then break out of the for loop.

Pseudocode:
Code:

new bool:admin_found = false

start loop
    if player is admin
        admin_found = true
        break
end loop

if( !admin_found )
    print "no admins online"



All times are GMT -4. The time now is 05:09.

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