Raised This Month: $51 Target: $400
 12% 

Why this loop not run for all clients?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
uurbyrkdr
Senior Member
Join Date: Apr 2015
Old 08-18-2015 , 16:01   Why this loop not run for all clients?
Reply With Quote #1

PHP Code:
public OnPluginStart() 
{
    
HookEvent("round_start"Event_RoundStart);
}

public 
Action Event_RoundStart(Handle eventchar[] namebool dontBroadcast)
{
    new 
i;
    for(
i=1i<=64i++)
    {
        
PrintToChatAll("Test Loop: %d"i);
        
// Bla bla
    
}

and this returns this:

Test Loop: 1
Test Loop: 2
Test Loop: 3
Test Loop: 4
Test Loop: 5
Test Loop: 6
Test Loop: 7
Test Loop: 8

sometimes until 17, ...

idk why didn't loop everyone?
i think this code must run until 64..

Last edited by uurbyrkdr; 08-18-2015 at 16:02.
uurbyrkdr is offline
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 08-18-2015 , 16:06   Re: Why this loop not run for all clients?
Reply With Quote #2

PHP Code:
for(int i 1<= MaxClientsi++)
{
if(
IsClientInGame(i))
{
PrintToChat(i"Hi");
}

__________________
SourcePawn, C# and C++ Programmer.

My plugin list

Last edited by TheUnderTaker; 08-18-2015 at 16:07.
TheUnderTaker is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 08-18-2015 , 16:08   Re: Why this loop not run for all clients?
Reply With Quote #3

mayhap there's a limit to chat messages per tick!
Miu is offline
uurbyrkdr
Senior Member
Join Date: Apr 2015
Old 08-18-2015 , 16:36   Re: Why this loop not run for all clients?
Reply With Quote #4

Quote:
Originally Posted by TheUnderTaker View Post
PHP Code:
for(int i 1<= MaxClientsi++)
{
if(
IsClientInGame(i))
{
PrintToChat(i"Hi");
}


o.O

now works, thanks!
uurbyrkdr is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 08-18-2015 , 18:37   Re: Why this loop not run for all clients?
Reply With Quote #5

Quote:
Originally Posted by uurbyrkdr View Post
o.O

now works, thanks!
If you had checked the error logs (addons/sourcmod/logs/errors_*) you would see errors that would've hinted at what the issue was.
__________________
splewis is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 08-18-2015 , 21:33   Re: Why this loop not run for all clients?
Reply With Quote #6

he did printtochatall not printtochat
so his code should work
8guawong is offline
uurbyrkdr
Senior Member
Join Date: Apr 2015
Old 08-19-2015 , 01:03   Re: Why this loop not run for all clients?
Reply With Quote #7

i added only this, and now my code working.

PHP Code:
if(IsClientInGame(i)) 
uurbyrkdr is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 08-19-2015 , 02:47   Re: Why this loop not run for all clients?
Reply With Quote #8

Quote:
Originally Posted by 8guawong View Post
he did printtochatall not printtochat
so his code should work
PrintToChat() stops when a client is not valid.

so it must be stopped.
__________________
Starbish is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 08-19-2015 , 03:48   Re: Why this loop not run for all clients?
Reply With Quote #9

Quote:
Originally Posted by Starbish View Post
PrintToChat() stops when a client is not valid.

so it must be stopped.
thats why i said he used PrintToChatAll....
8guawong is offline
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 08-19-2015 , 04:48   Re: Why this loop not run for all clients?
Reply With Quote #10

Quote:
Originally Posted by uurbyrkdr View Post
o.O

now works, thanks!
NP
__________________
SourcePawn, C# and C++ Programmer.

My plugin list
TheUnderTaker 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 00:23.


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