PDA

View Full Version : potential infinite loop in script



feanor
18th July 2017, 11:16
what is problem in that script ?


fpslimit()
{
self endon ("disconnect");

kick_level = 0;
fps_time = 0;


while(isPlayer())
{

self.fps = self getFps();

if(self.fps < 250)
fps_time = 0 ;
else
fps_time ++ ;
if(fps_time == 5){
if(kick_level == 0){
self iPrintLn("com_maxfps must be set to 250 or below 250");
wait 2;
kick_level ++ ;
}
else{
userid = self getEntityNumber();
self iPrintLn("com_maxfps must be set to 250 or below 250");
wait 2;
kick (userid) ;
}
fps_time = 0;
}


}
}


its for while a player connected(there is not wrong here , only above script have infinite loop)


Init()
{
level thread MonitorPlayerConnect();
level thread OnFrameUpdate();
}

OnFrameUpdate()
{
while( true )
{
fpsNextFrame();

wait( 0.05 );
}
}

MonitorPlayerConnect()
{
while( true )
{
level waittill( "connected" , player );

if( !isDefined( player ) || !isPlayer( player ) )
continue;

level thread OnClientFrameUpdate( player );
}
}

OnClientFrameUpdate( player )
{
player resetFps();
}

IzNoGoD
18th July 2017, 13:49
There's no wait in your loop.

feanor
19th July 2017, 17:40
any idea about pam mod sd, i can not read players fps accurately , it shows me as 3/5 rate..

feanor
19th July 2017, 18:27
lol , i have changed fpsnextframe() in a 0.1 wait loop , when i have 250 fps server was reading me as i have 333 fps

feanor
20th July 2017, 16:05
bump , any ideas ? whats wrong

IzNoGoD
20th July 2017, 19:39
The getfps thing was updated a few weeks ago, it doesnt use nextframe stuff anymore.

feanor
20th July 2017, 19:53
i compiled mitch's libcod 4-5 days ago , is it include? and how to usage then without nextframe stuff ?

IzNoGoD
20th July 2017, 22:10
It's in voron's version.

genez_x
29th July 2017, 01:37
doesnt work well that (self getfps()), does not show the correct fps of the player on a server because it varies between 230 270 if the player has 250fps: at least use <280

ps:when you are tryng that on local it varies between 240-260,i think the more ping you have the bigger the ping oscillation

voron00
29th July 2017, 11:37
Who said it will be 100% accurate?

Lonsofore
29th July 2017, 13:12
doesnt work well that (self getfps()), does not show the correct fps of the player on a server because it varies between 230 270 if the player has 250fps: at least use <280

ps:when you are tryng that on local it varies between 240-260,i think the more ping you have the bigger the ping oscillation

If you need a real fps, you can take it 10 (more or less) times and take average value of it.

feanor
29th July 2017, 14:10
i am using voron00's libcod
it shows me 252 fps while put com_maxfps 250 , i changed my fps limit to 255 to dont kick innocent players. so its working well for me

voron00
29th July 2017, 14:41
roundFps(fps)
{
if (fps < 342 && fps > 319)
return 333;
else if (fps < 253 && fps > 237)
return 250;
else if (fps < 131 && fps > 119)
return 125;
else if (fps < 22 && fps > 18)
return 20;
else
return fps;
}

Something like this can work.