Saving causing lag for brief moment?
#1

Ok, So I'm currently using a time for my server points system it checks how many points the player has, but if the player has the amount of points to level up when the timer levels them up the server just totally lags for about 2-3 seconds (Freezes) Then everything go's normal again heres my code:

Код:
public ServerPoints(playerid)
{
for(new i; i<MAX_PLAYERS;i++) {
  if(serverpoints[i] >= 1000)
  {
 	new file[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(i, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
	serverrank[i] = serverrank[i]+1;
	serverpoints[i] -= 1000;
  dini_IntSet(file, "serverrank", serverrank[i]);
  dini_IntSet(file, "serverpoints", serverpoints[i]);
  GetPlayerName(i, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  dini_IntSet(file, "serverrank", serverrank[i]);
  new str[128]; format(str, sizeof(str), "You have been promoted to server rank %d !", serverrank[i]);
  PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  SendClientMessage(i, red, str);
  }
}
}
Reply
#2

Use IsPlayerConnected(i) in your loop, to filter out players which are actually there.
Reply
#3

yeah like

for(new i; i<MAX_PLAYERS;i++) && if(IsPlayerConnected(i))
{
Reply
#4

Also you really should learn how to use buffers for file I/O and single strings, if two hundred people are connected then that's going to use like Dini_IntSet six hundred times not to mention formats and names etc.

Howcome there is a 'playerid' argument for your timed function anyway, you only use it within the loop for the sound, typo ?

@Brett:

pawn Код:
for ( ...... )
{
  if ( IsPlayerConnect......
  {
    //code
Reply
#5

aha yea that sound is a error i just noticed thanks to you ty for all ur help guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)