From 9800b8f00764b89061fbff90555ad3854f44233c Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Mon, 22 Oct 2018 18:33:10 +1100 Subject: [PATCH] remove help dialog when a player spawns ... fix issue with supa not hiding help dialog --- gamemodes/irresistible/cnr/entrances.pwn | 11 ++++ .../cnr/features/robbery/safes.pwn | 25 ++++++++ gamemodes/sf-cnr.pwn | 59 ++++++++----------- 3 files changed, 60 insertions(+), 35 deletions(-) diff --git a/gamemodes/irresistible/cnr/entrances.pwn b/gamemodes/irresistible/cnr/entrances.pwn index 9bd50f0..a88d5cf 100644 --- a/gamemodes/irresistible/cnr/entrances.pwn +++ b/gamemodes/irresistible/cnr/entrances.pwn @@ -364,3 +364,14 @@ stock GetEntrancePos( entranceid, &Float: X, &Float: Y, &Float: Z ) { Y = g_entranceData[ entranceid ] [ E_EY ]; Z = g_entranceData[ entranceid ] [ E_EZ ]; } + +stock GetEntranceInsidePos( entranceid, &Float: X, &Float: Y, &Float: Z ) { + X = g_entranceData[ entranceid ] [ E_LX ]; + Y = g_entranceData[ entranceid ] [ E_LY ]; + Z = g_entranceData[ entranceid ] [ E_LZ ]; + return 1; +} + +stock GetEntranceWorld( entranceid ) { + return g_entranceData[ entranceid ] [ E_WORLD ]; +} diff --git a/gamemodes/irresistible/cnr/features/robbery/safes.pwn b/gamemodes/irresistible/cnr/features/robbery/safes.pwn index 631e730..4dd7d0a 100644 --- a/gamemodes/irresistible/cnr/features/robbery/safes.pwn +++ b/gamemodes/irresistible/cnr/features/robbery/safes.pwn @@ -334,6 +334,31 @@ stock getClosestRobberySafe( playerid, &Float: dis = 99999.99 ) return object; } +stock GetEntranceClosestRobberySafe( entranceid, &Float: distance = FLOAT_INFINITY ) +{ + new iCurrent = INVALID_PLAYER_ID, Float: fTmp; + new world = GetEntranceWorld( entranceid ); + + foreach ( new robberyid : RobberyCount ) + { + if ( world != 0 && g_robberyData[ robberyid ] [ E_WORLD ] != -1 && g_robberyData[ robberyid ] [ E_WORLD ] != world ) + continue; + + static + Float: X, Float: Y, Float: Z; + + if ( GetEntranceInsidePos( entranceid, X, Y, Z ) ) + { + if ( 0.0 < ( fTmp = GetDistanceBetweenPoints( g_robberyData[ robberyid ] [ E_DOOR_X ], g_robberyData[ robberyid ] [ E_DOOR_Y ], g_robberyData[ robberyid ] [ E_DOOR_Z ], X, Y, Z ) ) < distance ) // Y_Less mentioned there's no need to sqroot + { + distance = fTmp; + iCurrent = robberyid; + } + } + } + return iCurrent; +} + stock GetXYInFrontOfSafe( robberyid, &Float: X, &Float: Y, &Float: Z, Float: distance = 1.1 ) // old 1.25 { static diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index aafa788..55e7598 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -1731,6 +1731,7 @@ public OnPlayerSpawn( playerid ) p_InGarage[ playerid ] = -1; StopSound( playerid ); CancelEdit( playerid ); + HidePlayerHelpDialog( playerid ); // Money Bags if ( p_MoneyBag{ playerid } && p_Class[ playerid ] != CLASS_POLICE ) // SetPlayerAttachedObject( playerid, 1, 1550, 1, 0.131999, -0.140999, 0.053999, 11.299997, 65.599906, 173.900054, 0.652000, 0.573000, 0.594000 ); @@ -7390,6 +7391,25 @@ public OnPlayerAccessEntrance( playerid, entranceid ) if ( g_entranceData[ entranceid ] [ E_VIP ] && p_VIPLevel[ playerid ] < VIP_REGULAR ) { return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" ), 0; } + + // robbery helper + if ( p_Class[ playerid ] != CLASS_POLICE ) + { + if ( ! IsPlayerInBank( playerid ) ) p_SafeHelperTimer[ playerid ] = SetTimerEx( "OnSafeHelperUpdate", 500, false, "dd", playerid, GetEntranceClosestRobberySafe( entranceid ) ); + else + { + new iCity, iWorld = GetPlayerVirtualWorld( playerid ); + + for( iCity = 0; iCity < sizeof( g_bankvaultData ); iCity++ ) + if ( iWorld != 0 && iWorld == g_bankvaultData[ iCity ] [ E_WORLD ] ) + break; + + if ( g_bankvaultData[ iCity ] [ E_TIMESTAMP ] < g_iTime && !g_bankvaultData[ iCity ] [ E_DISABLED ] ) + ShowPlayerHelpDialog( playerid, 5000, "This ~g~~h~bank~w~~h~ is available for a heist." ); + else + ShowPlayerHelpDialog( playerid, 5000, "This bank is ~r~~h~unavailable for a heist." ); + } + } return 1; } @@ -7503,42 +7523,14 @@ public OnPlayerExitedMenu( playerid ) public OnPlayerInteriorChange( playerid, newinteriorid, oldinteriorid ) { - if ( p_InHouse[ playerid ] == -1 && p_LastEnteredEntrance[ playerid ] != -1 && newinteriorid != 0 && oldinteriorid == 0 && p_Class[ playerid ] != CLASS_POLICE ) { - - if ( !IsPlayerInBank( playerid ) ) p_SafeHelperTimer[ playerid ] = SetTimerEx( "OnSafeHelperUpdate", 500, false, "dd", playerid, -1 ); - else - { - new - iCity, - iWorld = GetPlayerVirtualWorld( playerid ) - ; - - for( iCity = 0; iCity < sizeof( g_bankvaultData ); iCity++ ) - if ( iWorld != 0 && iWorld == g_bankvaultData[ iCity ] [ E_WORLD ] ) - break; - - if ( g_bankvaultData[ iCity ] [ E_TIMESTAMP ] < g_iTime && !g_bankvaultData[ iCity ] [ E_DISABLED ] ) - ShowPlayerHelpDialog( playerid, 5000, "This ~g~~h~bank~w~~h~ is available for a heist." ); - else - ShowPlayerHelpDialog( playerid, 5000, "This bank is ~r~~h~unavailable for a heist." ); - } - } - SyncSpectation( playerid ); return 1; } function OnSafeHelperUpdate( playerid, robberyid ) { - if ( robberyid == -1 ) - { - p_SafeHelperTimer[ playerid ] = SetTimerEx( "OnSafeHelperUpdate", 500, false, "dd", playerid, getClosestRobberySafe( playerid ) ); - return 1; - } - new - Float: distance = distanceFromSafe( playerid, robberyid ) - ; + Float: distance = distanceFromSafe( playerid, robberyid ); if ( robberyid == INVALID_OBJECT_ID || distance > 100.0 || ! IsPlayerConnected( playerid ) || ! IsPlayerSpawned( playerid ) || IsPlayerInCasino( playerid ) || IsPlayerPlayingPool( playerid ) ) { @@ -7554,7 +7546,7 @@ function OnSafeHelperUpdate( playerid, robberyid ) return 0; } - if ( distance < 2.0 ) + if ( 0.0 < distance < 2.0 ) { p_SafeHelperTimer[ playerid ] = -1; ShowPlayerHelpDialog( playerid, 7500, "Great, you've ~g~~h~found the safe.~w~~h~~n~~n~To rob the safe, hit ~r~~h~Left Alt~w~~h~ key." ); @@ -12032,11 +12024,8 @@ stock ShowPlayerHelpDialog( playerid, timeout, format[ ], va_args<> ) function HidePlayerHelpDialog( playerid ) { - if ( p_HideHelpDialogTimer[ playerid ] != -1 ) - { - p_HideHelpDialogTimer[ playerid ] = -1; - PlayerTextDrawHide( playerid, p_HelpBoxTD[ playerid ] ); - } + p_HideHelpDialogTimer[ playerid ] = -1; + PlayerTextDrawHide( playerid, p_HelpBoxTD[ playerid ] ); } stock fix_NightThermalVisionHack( playerid ) // Created by wups