From c652ac40e2a02fd5574cc578437ed531d45f29dd Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Wed, 10 Oct 2018 16:05:14 +1100 Subject: [PATCH] GetPlayerOutsidePos will give you the entrance/house/garage/pos the player is at --- .../cnr/features/houses/house.pwn | 6 ++ .../cnr/features/vehicles/garages.pwn | 6 ++ gamemodes/sf-cnr.pwn | 69 +++++-------------- 3 files changed, 30 insertions(+), 51 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/houses/house.pwn b/gamemodes/irresistible/cnr/features/houses/house.pwn index 2bb6f44..2298c01 100644 --- a/gamemodes/irresistible/cnr/features/houses/house.pwn +++ b/gamemodes/irresistible/cnr/features/houses/house.pwn @@ -867,3 +867,9 @@ stock ArePlayersInHouse( houseid, owner ) } return false; } + +stock GetHousePos( houseid, &Float: X, &Float: Y, &Float: Z ) { + X = g_houseData[ houseid ] [ E_EX ]; + Y = g_houseData[ houseid ] [ E_EY ]; + Z = g_houseData[ houseid ] [ E_EZ ]; +} diff --git a/gamemodes/irresistible/cnr/features/vehicles/garages.pwn b/gamemodes/irresistible/cnr/features/vehicles/garages.pwn index f43de3d..f9c6b85 100644 --- a/gamemodes/irresistible/cnr/features/vehicles/garages.pwn +++ b/gamemodes/irresistible/cnr/features/vehicles/garages.pwn @@ -566,3 +566,9 @@ stock GetGarageInteriorID( garageid ) { stock GetGarageVirtualWorld( garageid ) { return g_garageData[ garageid ] [ E_WORLD ]; } + +stock GetGaragePos( garageid, &Float: X, &Float: Y, &Float: Z ) { + X = g_garageData[ garageid ] [ E_X ]; + Y = g_garageData[ garageid ] [ E_Y ]; + Z = g_garageData[ garageid ] [ E_Z ]; +} diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 6954929..6996bab 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -17115,40 +17115,18 @@ stock isNotNearPlayer( playerid, nearid, Float: distance = 200.0 ) if ( ! IsPlayerNPC( playerid ) && ( GetTickCount( ) - p_AFKTime[ playerid ] ) >= 500 ) return 0; - if ( !IsPlayerConnected( nearid ) ) + if ( ! IsPlayerConnected( nearid ) ) return 1; if ( IsPlayerAFK( nearid ) ) return 1; new - Float: fDistance = 9999.9, - Float: X, Float: Y, Float: Z, + Float: X, Float: Y, Float: Z; - // Get kidnapper data - iEntrance = p_LastEnteredEntrance[ nearid ], - iHouse = p_InHouse[ nearid ], - iGarage = p_InGarage[ nearid ] - ; + GetPlayerOutsidePos( nearid, X, Y, Z ); - GetPlayerPos( nearid, X, Y, Z ); - - if ( GetPlayerInterior( playerid ) != GetPlayerInterior( nearid ) && GetPlayerVirtualWorld( playerid ) != GetPlayerVirtualWorld( nearid ) ) - { - if ( iEntrance != -1 ) - fDistance = GetPlayerDistanceFromPoint( playerid, g_entranceData[ iEntrance ] [ E_EX ], g_entranceData[ iEntrance ] [ E_EY ], g_entranceData[ iEntrance ] [ E_EZ ] ); - - else if ( iGarage != -1 ) - fDistance = GetPlayerDistanceFromPoint( playerid, g_garageData[ iGarage ] [ E_X ], g_garageData[ iGarage ] [ E_Y ], g_garageData[ iGarage ] [ E_Z ] ); - - else if ( iHouse != -1 ) - fDistance = GetPlayerDistanceFromPoint( playerid, g_houseData[ iHouse ] [ E_EX ], g_houseData[ iHouse ] [ E_EY ], g_houseData[ iHouse ] [ E_EZ ] ); - - else fDistance = GetPlayerDistanceFromPoint( playerid, X, Y, Z ); - } - else fDistance = GetPlayerDistanceFromPoint( playerid, X, Y, Z ); - - return fDistance > distance ? 1 : 0; + return GetPlayerDistanceFromPoint( playerid, X, Y, Z ) > distance ? 1 : 0; } stock GetVehicleDriver( vehicleid ) @@ -17208,23 +17186,12 @@ stock IsDeathmatchProtectedZone( playerid ) { return false; }*/ -stock GetPlayerLocation( iPlayer, szCity[ ], szLocation[ ] ) { +stock GetPlayerLocation( iPlayer, szCity[ ], szLocation[ ] ) +{ static Float: X, Float: Y, Float: Z; - if ( GetPlayerInterior( iPlayer ) != 0 || IsPlayerInBank( iPlayer ) ) { - new - iEntrance = p_LastEnteredEntrance[ iPlayer ], - iHouse = p_InHouse[ iPlayer ], - iGarage = p_InGarage[ iPlayer ] - ; - - if ( iEntrance != -1 ) GetEntrancePos( iEntrance, X, Y, Z ); - else if ( iGarage != -1 ) X = g_garageData[ iGarage ] [ E_X ], Y = g_garageData[ iGarage ] [ E_Y ], Z = g_garageData[ iGarage ] [ E_Z ]; - else if ( iHouse != -1 ) X = g_houseData[ iHouse ] [ E_EX ], Y = g_houseData[ iHouse ] [ E_EY ], Z = g_houseData[ iHouse ] [ E_EZ ]; - else return false; - } - else GetPlayerPos( iPlayer, X, Y, Z ); + GetPlayerOutsidePos( iPlayer, X, Y, Z ); Get2DCity( szCity, X, Y, Z ); GetZoneFromCoordinates( szLocation, X, Y, Z ); @@ -19113,24 +19080,24 @@ stock SendClientMessageToCops( colour, format[ ], va_args<> ) // Conversion to f return 1; } -stock GetPlayerOutsidePos( playerid, &Float: X, &Float: Y, &Float: Z ) // Gets the player position, if interior then the last checkpoint position +stock GetPlayerOutsidePos( playerid, &Float: X, &Float: Y, &Float: Z ) // gets the player position, if interior then the last checkpoint position { new - iEntrance = p_LastEnteredEntrance[ playerid ], - iHouse = p_InHouse[ playerid ], - iGarage = p_InGarage[ playerid ] + entranceid = p_LastEnteredEntrance[ playerid ], + houseid = p_InHouse[ playerid ], + garageid = p_InGarage[ playerid ] ; - if ( GetPlayerInterior( playerid ) != 0 ) + if ( GetPlayerInterior( playerid ) != 0 || IsPlayerInBank( playerid ) ) { - if ( iEntrance != -1 ) - GetEntrancePos( iEntrance, X, Y, Z ); + if ( entranceid != -1 ) + GetEntrancePos( entranceid, X, Y, Z ); - else if ( iGarage != -1 ) - X = g_garageData[ iGarage ] [ E_X ], Y = g_garageData[ iGarage ] [ E_Y ], Z = g_garageData[ iGarage ] [ E_Z ]; + else if ( garageid != -1 ) + GetGaragePos( garageid, X, Y, Z ); - else if ( iHouse != -1 ) - X = g_houseData[ iHouse ] [ E_EX ], Y = g_houseData[ iHouse ] [ E_EY ], Z = g_houseData[ iHouse ] [ E_EZ ]; + else if ( houseid != -1 ) + GetHousePos( houseid, X, Y, Z ); else GetPlayerPos( playerid, X, Y, Z ); }