From 803af66803da82238a578fbf3f3ec015dc68413e Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 23 Dec 2018 12:16:55 +1100 Subject: [PATCH] move fps code to module --- gamemodes/irresistible/cnr/features/fps.pwn | 24 +++++++++++++++++++-- gamemodes/sf-cnr.pwn | 8 ------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/fps.pwn b/gamemodes/irresistible/cnr/features/fps.pwn index a58a159..4757d34 100644 --- a/gamemodes/irresistible/cnr/features/fps.pwn +++ b/gamemodes/irresistible/cnr/features/fps.pwn @@ -1,7 +1,7 @@ /* * Irresistible Gaming (c) 2018 * Developed by Lorenc - * Module: fps.inc + * Module: cnr\features\fps.pwn * Purpose: fps counter in-game */ @@ -9,7 +9,7 @@ #include < YSI\y_hooks > /* ** Variables ** */ -new +static stock Text: p_FPSCounterTD [ MAX_PLAYERS ] = { Text: INVALID_TEXT_DRAW, ... }, bool: p_FPSCounter [ MAX_PLAYERS char ], p_FPS_DrunkLevel [ MAX_PLAYERS ], @@ -72,6 +72,26 @@ hook OnScriptInit( ) 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 ) { new diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index f46f1a1..ea28e6f 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -512,7 +512,6 @@ public OnPlayerRequestClass( playerid, classid ) PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] ); TextDrawHideForPlayer( playerid, g_MotdTD ); PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] ); - TextDrawHideForPlayer( playerid, p_FPSCounterTD[ playerid ] ); TextDrawHideForPlayer( playerid, g_AdminOnDutyTD ); TextDrawHideForPlayer( playerid, g_WorldDayTD ); PlayerTextDrawHide( playerid, p_LocationTD[ playerid ] ); @@ -617,8 +616,6 @@ public OnPlayerConnect( playerid ) p_GangID [ playerid ] = INVALID_GANG_ID; justConnected { playerid } = true; p_ClassSelection { playerid } = false; - p_FPS_DrunkLevel [ playerid ] = 0; - p_FPS [ playerid ] = 0; p_UsingRobberySafe [ playerid ] = -1; // reset jails @@ -819,7 +816,6 @@ public OnPlayerDisconnect( playerid, reason ) p_Kidnapped { playerid } = false; p_Wood [ playerid ] = 0; p_inAlcatraz { playerid } = false; - p_FPSCounter { playerid } = false; p_Ropes [ playerid ] = 0; p_Scissors [ playerid ] = 0; p_Fires [ playerid ] = 0; @@ -1005,7 +1001,6 @@ public OnPlayerSpawn( playerid ) TextDrawShowForPlayer( playerid, g_WorldDayTD ); if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD ); if ( p_AdminLog{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminLogTD ); - if ( p_FPSCounter{ playerid } ) TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] ); if ( IsDoubleXP( ) ) TextDrawShowForPlayer( playerid, g_DoubleXPTD ); CallLocalFunction( "OnPlayerLoadTextdraws", "d", playerid ); } @@ -1636,7 +1631,6 @@ public OnPlayerDeath( playerid, killerid, reason ) PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] ); TextDrawHideForPlayer( playerid, g_MotdTD ); PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] ); - TextDrawHideForPlayer( playerid, p_FPSCounterTD[ playerid ] ); TextDrawHideForPlayer( playerid, g_AdminOnDutyTD ); TextDrawHideForPlayer( playerid, g_WorldDayTD ); TextDrawHideForPlayer( playerid, g_AdminLogTD ); @@ -3250,7 +3244,6 @@ public OnPlayerLoadTextdraws( playerid ) TextDrawShowForPlayer( playerid, g_WebsiteTD ); if ( p_WantedLevel[ playerid ] ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] ); TextDrawShowForPlayer( playerid, g_MotdTD ); - if ( p_FPSCounter{ playerid } ) TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] ); if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD ); TextDrawShowForPlayer( playerid, g_WorldDayTD ); PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] ); @@ -3268,7 +3261,6 @@ public OnPlayerUnloadTextdraws( playerid ) TextDrawHideForPlayer( playerid, g_DoubleXPTD ); TextDrawHideForPlayer( playerid, g_MotdTD ); TextDrawHideForPlayer( playerid, g_WorldDayTD ); - TextDrawHideForPlayer( playerid, p_FPSCounterTD[ playerid ] ); return 1; }