Saving causing lag for brief moment? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving causing lag for brief moment? (
/showthread.php?tid=99962)
Saving causing lag for brief moment? -
[mad]MLK - 01.10.2009
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);
}
}
}
Re: Saving causing lag for brief moment? -
Sergei - 01.10.2009
Use IsPlayerConnected(i) in your loop, to filter out players which are actually there.
Re: Saving causing lag for brief moment? -
brett7 - 01.10.2009
yeah like
for(new i; i<MAX_PLAYERS;i++) && if(IsPlayerConnected(i))
{
Re: Saving causing lag for brief moment? -
Donny_k - 01.10.2009
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
Re: Saving causing lag for brief moment? -
[mad]MLK - 01.10.2009
aha yea that sound is a error i just noticed thanks to you
ty for all ur help guys