19.05.2016, 06:03
PHP код:
LoadObjectsForPlayer(playerid)
{
if( IsPlayerConnected ( playerid ) )//checking if the player is connected
{
TogglePlayerControllable( playerid, false ); // Freezing the player
if( GetPlayerPing ( playerid ) < 100 )
{
SetTimerEx( "ObjectsLoaded", 3000, 0, "i", playerid );
}//the value of Time should be increased upon increasing ping
if( GetPlayerPing ( playerid ) >=100 )
{
SetTimerEx( "ObjectsLoaded", 3000, 0, "i", playerid );
}// i stands for integer we passing playerid to function
if( GetPlayerPing ( playerid ) >= 200 && GetPlayerPing ( playerid )<300 )
{
SetTimerEx( "ObjectsLoaded", 3200, 0, "i", playerid );
}
if( GetPlayerPing ( playerid ) >=300 && GetPlayerPing ( playerid )<500 )
{
SetTimerEx( "ObjectsLoaded", 3700, 0, "i", playerid );
}
if( GetPlayerPing ( playerid ) >= 500)
{
SetTimerEx( "ObjectsLoaded", 4000, 0, "i", playerid );
}
else
{
SetTimerEx( "ObjectsLoaded", 5000, 0, "i", playerid );
}
}
return 1;
}
forward ObjectsLoaded(playerid);
public ObjectsLoaded(playerid)
{
if( IsPlayerConnected ( playerid ) ) return TogglePlayerControllable( playerid, true );
return 1;
}
PHP код:
LoadObjectsForPlayer( playerid )
{
if( IsPlayerConnected ( playerid ) )
{
TogglePlayerControllable( playerid, 0 );
if( GetPlayerPing ( playerid ) < 100 ) { SetTimerEx( "ObjectsLoaded", 3000, 0, "i", playerid );}
if( GetPlayerPing ( playerid ) >= 100 ) { SetTimerEx( "ObjectsLoaded", 3000, 0, "i", playerid ); }
if( GetPlayerPing ( playerid ) >= 200 && GetPlayerPing ( playerid )<300 ) { SetTimerEx( "ObjectsLoaded", 3200, 0, "i", playerid ); }
if( GetPlayerPing ( playerid ) >= 300 && GetPlayerPing ( playerid )<500 ) { SetTimerEx( "ObjectsLoaded", 3700, 0, "i", playerid ); }
if( GetPlayerPing ( playerid ) >= 500) { SetTimerEx( "ObjectsLoaded", 4000, 0, "i", playerid ); }
else { SetTimerEx( "ObjectsLoaded", 5000, 0, "i", playerid ); }
}
return 1;
}