14.01.2014, 22:14
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:
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); }