Raised This Month: $ Target: $400
 0% 

how to print only one time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 09-05-2015 , 01:13   how to print only one time
Reply With Quote #1

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

Attached Files
File Type: sma Get Plugin or Get Source (test.sma - 483 views - 335 Bytes)
indraraj striker is offline
Hartmann
Senior Member
Join Date: Nov 2014
Old 09-05-2015 , 06:52   Re: how to print only one time
Reply With Quote #2

Try with 0 --> tempid
__________________

RETAKES v1.0
github.com/alghtryer/retakes

Contact : [email protected]

BTC Donate: 1QAh1NLmeHy81LF9r8PaeGjYqHL2BBcJTx

Hartmann is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 09-05-2015 , 07:44   Re: how to print only one time
Reply With Quote #3

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); 
indraraj striker is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-05-2015 , 11:46   Re: how to print only one time
Reply With Quote #4

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"
__________________

Last edited by fysiks; 09-05-2015 at 11:46.
fysiks 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 06:35.


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