move fps code to module

This commit is contained in:
Lorenc Pekaj 2018-12-23 12:16:55 +11:00
parent 98231fdb58
commit 803af66803
2 changed files with 22 additions and 10 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Irresistible Gaming (c) 2018 * Irresistible Gaming (c) 2018
* Developed by Lorenc * Developed by Lorenc
* Module: fps.inc * Module: cnr\features\fps.pwn
* Purpose: fps counter in-game * Purpose: fps counter in-game
*/ */
@ -9,7 +9,7 @@
#include < YSI\y_hooks > #include < YSI\y_hooks >
/* ** Variables ** */ /* ** Variables ** */
new static stock
Text: p_FPSCounterTD [ MAX_PLAYERS ] = { Text: INVALID_TEXT_DRAW, ... }, Text: p_FPSCounterTD [ MAX_PLAYERS ] = { Text: INVALID_TEXT_DRAW, ... },
bool: p_FPSCounter [ MAX_PLAYERS char ], bool: p_FPSCounter [ MAX_PLAYERS char ],
p_FPS_DrunkLevel [ MAX_PLAYERS ], p_FPS_DrunkLevel [ MAX_PLAYERS ],
@ -72,6 +72,26 @@ hook OnScriptInit( )
return 1; return 1;
} }
hook OnPlayerConnect( playerid )
{
p_FPSCounter{ playerid } = false;
p_FPS_DrunkLevel[ playerid ] = 0;
p_FPS[ playerid ] = 0;
return 1;
}
hook OnPlayerLoadTextdraws( playerid ) {
if ( p_FPSCounter{ playerid } ) {
TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] );
}
return 1;
}
hook OnPlayerUnloadTextdraws( playerid ) {
TextDrawHideForPlayer( playerid, p_FPSCounterTD[ playerid ] );
return 1;
}
hook OnPlayerUpdate( playerid ) hook OnPlayerUpdate( playerid )
{ {
new new

View File

@ -512,7 +512,6 @@ public OnPlayerRequestClass( playerid, classid )
PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] ); PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] );
TextDrawHideForPlayer( playerid, g_MotdTD ); TextDrawHideForPlayer( playerid, g_MotdTD );
PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] ); PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] );
TextDrawHideForPlayer( playerid, p_FPSCounterTD[ playerid ] );
TextDrawHideForPlayer( playerid, g_AdminOnDutyTD ); TextDrawHideForPlayer( playerid, g_AdminOnDutyTD );
TextDrawHideForPlayer( playerid, g_WorldDayTD ); TextDrawHideForPlayer( playerid, g_WorldDayTD );
PlayerTextDrawHide( playerid, p_LocationTD[ playerid ] ); PlayerTextDrawHide( playerid, p_LocationTD[ playerid ] );
@ -617,8 +616,6 @@ public OnPlayerConnect( playerid )
p_GangID [ playerid ] = INVALID_GANG_ID; p_GangID [ playerid ] = INVALID_GANG_ID;
justConnected { playerid } = true; justConnected { playerid } = true;
p_ClassSelection { playerid } = false; p_ClassSelection { playerid } = false;
p_FPS_DrunkLevel [ playerid ] = 0;
p_FPS [ playerid ] = 0;
p_UsingRobberySafe [ playerid ] = -1; p_UsingRobberySafe [ playerid ] = -1;
// reset jails // reset jails
@ -819,7 +816,6 @@ public OnPlayerDisconnect( playerid, reason )
p_Kidnapped { playerid } = false; p_Kidnapped { playerid } = false;
p_Wood [ playerid ] = 0; p_Wood [ playerid ] = 0;
p_inAlcatraz { playerid } = false; p_inAlcatraz { playerid } = false;
p_FPSCounter { playerid } = false;
p_Ropes [ playerid ] = 0; p_Ropes [ playerid ] = 0;
p_Scissors [ playerid ] = 0; p_Scissors [ playerid ] = 0;
p_Fires [ playerid ] = 0; p_Fires [ playerid ] = 0;
@ -1005,7 +1001,6 @@ public OnPlayerSpawn( playerid )
TextDrawShowForPlayer( playerid, g_WorldDayTD ); TextDrawShowForPlayer( playerid, g_WorldDayTD );
if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD ); if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD );
if ( p_AdminLog{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminLogTD ); if ( p_AdminLog{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminLogTD );
if ( p_FPSCounter{ playerid } ) TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] );
if ( IsDoubleXP( ) ) TextDrawShowForPlayer( playerid, g_DoubleXPTD ); if ( IsDoubleXP( ) ) TextDrawShowForPlayer( playerid, g_DoubleXPTD );
CallLocalFunction( "OnPlayerLoadTextdraws", "d", playerid ); CallLocalFunction( "OnPlayerLoadTextdraws", "d", playerid );
} }
@ -1636,7 +1631,6 @@ public OnPlayerDeath( playerid, killerid, reason )
PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] ); PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] );
TextDrawHideForPlayer( playerid, g_MotdTD ); TextDrawHideForPlayer( playerid, g_MotdTD );
PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] ); PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] );
TextDrawHideForPlayer( playerid, p_FPSCounterTD[ playerid ] );
TextDrawHideForPlayer( playerid, g_AdminOnDutyTD ); TextDrawHideForPlayer( playerid, g_AdminOnDutyTD );
TextDrawHideForPlayer( playerid, g_WorldDayTD ); TextDrawHideForPlayer( playerid, g_WorldDayTD );
TextDrawHideForPlayer( playerid, g_AdminLogTD ); TextDrawHideForPlayer( playerid, g_AdminLogTD );
@ -3250,7 +3244,6 @@ public OnPlayerLoadTextdraws( playerid )
TextDrawShowForPlayer( playerid, g_WebsiteTD ); TextDrawShowForPlayer( playerid, g_WebsiteTD );
if ( p_WantedLevel[ playerid ] ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] ); if ( p_WantedLevel[ playerid ] ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] );
TextDrawShowForPlayer( playerid, g_MotdTD ); TextDrawShowForPlayer( playerid, g_MotdTD );
if ( p_FPSCounter{ playerid } ) TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] );
if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD ); if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD );
TextDrawShowForPlayer( playerid, g_WorldDayTD ); TextDrawShowForPlayer( playerid, g_WorldDayTD );
PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] ); PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] );
@ -3268,7 +3261,6 @@ public OnPlayerUnloadTextdraws( playerid )
TextDrawHideForPlayer( playerid, g_DoubleXPTD ); TextDrawHideForPlayer( playerid, g_DoubleXPTD );
TextDrawHideForPlayer( playerid, g_MotdTD ); TextDrawHideForPlayer( playerid, g_MotdTD );
TextDrawHideForPlayer( playerid, g_WorldDayTD ); TextDrawHideForPlayer( playerid, g_WorldDayTD );
TextDrawHideForPlayer( playerid, p_FPSCounterTD[ playerid ] );
return 1; return 1;
} }