thrown more items into the fps module

This commit is contained in:
Lorenc Pekaj 2018-09-11 17:40:36 +10:00
parent a99e86216b
commit 759ee28afb
3 changed files with 49 additions and 40 deletions

View File

@ -1,8 +1,8 @@
/* /*
* Irresistible Gaming (c) 2018 * Irresistible Gaming (c) 2018
* Developed by Lorenc Pekaj * Developed by Lorenc Pekaj
* Module: * Module: cnr\features\chuffsec.pwn
* Purpose: * Purpose: robbable npc security truck implementation
*/ */
/* ** Error checking ** */ /* ** Error checking ** */

View File

@ -1,5 +1,5 @@
/* /*
* Irresistible Gaming 2018 * Irresistible Gaming (c) 2018
* Developed by Lorenc Pekaj * Developed by Lorenc Pekaj
* Module: fps.inc * Module: fps.inc
* Purpose: fps counter in-game * Purpose: fps counter in-game
@ -21,7 +21,7 @@ CMD:fps( playerid, params[ ] )
{ {
if( ( p_FPSCounter{ playerid } = !p_FPSCounter{ playerid } ) == true ) if( ( p_FPSCounter{ playerid } = !p_FPSCounter{ playerid } ) == true )
{ {
formatFPSCounter( playerid ); TextDrawSetString( p_FPSCounterTD[ playerid ], "_" );
TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] ); TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] );
SendClientMessage( playerid, 0x84aa63ff, "-> FPS counter enabled" ); SendClientMessage( playerid, 0x84aa63ff, "-> FPS counter enabled" );
} }
@ -72,30 +72,56 @@ hook OnScriptInit( )
return 1; return 1;
} }
/* ** Functions ** */ hook OnPlayerUpdate( playerid )
stock formatFPSCounter( playerid )
{ {
if( !p_FPSCounter{ playerid } ) { new
return; iDrunkLevel = GetPlayerDrunkLevel( playerid );
}
static // Calculate FPS
iFPS, if ( iDrunkLevel < 100 ) SetPlayerDrunkLevel( playerid, 2000 );
szColor[ 10 ], else
szFPS[ sizeof( szColor ) + 4 ] {
; if ( p_FPS_DrunkLevel[ playerid ] != iDrunkLevel ) {
new iFPS = p_FPS_DrunkLevel[ playerid ] - iDrunkLevel;
switch( ( iFPS = p_FPS[ playerid ] ) ) { if ( ( iFPS > 0 ) && ( iFPS < 200 ) )
case 32 .. 120: szColor = "~g~~h~~h~"; p_FPS[ playerid ] = iFPS;
case 18 .. 31: szColor = "~y~~h~";
case 0 .. 17: szColor = "~r~~h~~h~";
default: szColor = "~g~~h~~h~";
}
format( szFPS, sizeof( szFPS ), "%s%d", szColor, iFPS ); p_FPS_DrunkLevel[ playerid ] = iDrunkLevel;
TextDrawSetString( p_FPSCounterTD[ playerid ], szFPS ); }
}
// format textdraw
if ( p_FPSCounter{ playerid } )
{
static
szFPS[ 14 ];
switch( p_FPS[ playerid ] )
{
case 32 .. 120: {
format( szFPS, sizeof( szFPS ), "~g~~h~~h~%d", p_FPS[ playerid ] );
}
case 18 .. 31: {
format( szFPS, sizeof( szFPS ), "~y~~h~%d", p_FPS[ playerid ] );
}
case 0 .. 17: {
format( szFPS, sizeof( szFPS ), "~r~~h~~h~%d", p_FPS[ playerid ] );
}
default: {
format( szFPS, sizeof( szFPS ), "~g~~h~~h~%d", p_FPS[ playerid ] );
}
}
TextDrawSetString( p_FPSCounterTD[ playerid ], szFPS );
}
return 1;
} }
/* ** Functions ** */
stock GetPlayerFPS( playerid ) { stock GetPlayerFPS( playerid ) {
return p_FPS[ playerid ]; return p_FPS[ playerid ];
} }

View File

@ -15128,7 +15128,7 @@ public OnPlayerUpdate( playerid )
Float: X, Float: Y, Float: Z, Float: X, Float: Y, Float: Z,
Float: vX, Float: vY, Float: vZ, Float: vX, Float: vY, Float: vZ,
iDrunkLevel, iKeys, iLeftRight, iState iKeys, iLeftRight, iState
; ;
if ( g_iTime < p_DesyncTime[ playerid ] ) if ( g_iTime < p_DesyncTime[ playerid ] )
@ -15152,23 +15152,6 @@ public OnPlayerUpdate( playerid )
SetPlayerAttachedObject( playerid, 1, 1210, 7, 0.302650, -0.002469, -0.193321, 296.124053, 270.396881, 8.941717, 1.000000, 1.000000, 1.000000 ); SetPlayerAttachedObject( playerid, 1, 1210, 7, 0.302650, -0.002469, -0.193321, 296.124053, 270.396881, 8.941717, 1.000000, 1.000000, 1.000000 );
} }
// FPS Counter
iDrunkLevel = GetPlayerDrunkLevel( playerid );
if ( iDrunkLevel < 100 ) SetPlayerDrunkLevel( playerid, 2000 );
else
{
if ( p_FPS_DrunkLevel[ playerid ] != iDrunkLevel ) {
new iFPS = p_FPS_DrunkLevel[ playerid ] - iDrunkLevel;
if ( ( iFPS > 0 ) && ( iFPS < 200 ) )
p_FPS[ playerid ] = iFPS;
p_FPS_DrunkLevel[ playerid ] = iDrunkLevel;
}
}
formatFPSCounter( playerid );
// Fugga.cs // Fugga.cs
GetPlayerVelocity( playerid, vX, vY, vZ ); GetPlayerVelocity( playerid, vX, vY, vZ );
if ( ( ( vX < -10.0 || vX > 10.0 ) && ( vZ > 1.0 || vZ < -1.0 ) ) || ( ( vX < -3.0 || vX > 3.0 ) && ( vY < -3.0 || vY > 3.0 ) && ( vZ > 3.0 || vZ < -3.0 ) ) ) if ( ( ( vX < -10.0 || vX > 10.0 ) && ( vZ > 1.0 || vZ < -1.0 ) ) || ( ( vX < -3.0 || vX > 3.0 ) && ( vY < -3.0 || vY > 3.0 ) && ( vZ > 3.0 || vZ < -3.0 ) ) )