SetTimer Question
#1

Hello, I v in my Gamemode SetTimer("Online",3000,1); which show's the online players with record, but the question is , iv putted it under OnGameModeInit() , if i got much players isnt this will cause a huge lagg?
Online Function:
Код:
forward Online();

public Online()
{
//---------------------- VARIABLES  --------------------------------------------
    On=0;
	Max_Online=0;
	Top_1=-1;
	Top_2=-1;
	Top_1_Player=-1;
	Top_2_Player=-1;
//---------------------   ONLINE    --------------------------------------------
	for(player_on=0;player_on<100;player_on++)
	    {
	        if(IsPlayerConnected(player_on))
	            {
	                On=On+1;
//-----------------------     TWO BEST     -------------------------------------
	                Score=GetPlayerScore(player_on);
	                if(Score>=Top_1)
	                    {
	                        if(Top_1_Player==-1)
	                            {
	                                Top_1=Score;
	                                Top_1_Player=player_on;
	                            }
							else
							    {
							        Top_2=Top_1;
							        Top_2_Player=Top_1_Player;
							        Top_1=Score;
	                        		Top_1_Player=player_on;
							    }
	                    }
					else
					    {
					        if((Score>=Top_2)&&(player_on>Top_1_Player))
					    		{
					        		Top_2=Score;
					        		Top_2_Player=player_on;
								}
					    }
//------------------------------------------------------------------------------
	            }
		}
//----------------------   MAX ONLINE ------------------------------------------
	On_txt=fopen("Max_Online.txt",io_readwrite);
	fread(On_txt,On_File_txt,32,false);
	fclose(On_txt);
	Max_Online=strval(On_File_txt);
	if(On>Max_Online)
		{
			On_txt=fopen("Max_Online.txt",io_readwrite);
			format(On_File_txt,32,"%i",On);
			fwrite(On_txt,On_File_txt);
			fclose(On_txt);
		}
//------------------------   PRINTING   ----------------------------------------
	GetPlayerName(Top_1_Player,Top_1_Name,32);
	GetPlayerName(Top_2_Player,Top_2_Name,32);
    format(Online_txt,255,"~w~Players Online: ~r~%i~n~~w~Max Record: ~r~%i~n~~g~Best Players:~n~~r~1. ~w~%s - ~r~%i~n~2. ~w~%s - ~r~%i",On,Max_Online,Top_1_Name,Top_1,Top_2_Name,Top_2);
	TextDrawHideForAll(OnPlayers);
	TextDrawSetString(OnPlayers,Online_txt);
	TextDrawShowForAll(OnPlayers);
}
Reply
#2

It shouldn't, These things basically only Lag when you put it under OnPlayerUpdate.
Reply
#3

Thanks for reply!
Reply
#4

Setting that timer under OnGameModeInit will do nothing. When you start your server, you don't have any players connected.
EDIT: sorry, I haven't understood you perfectly, but I got it now. Creating timers that are higher than one second won't do much trouble, you are fine with your timer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)