GetPlayerOutsidePos will give you the entrance/house/garage/pos the player is at

This commit is contained in:
Lorenc Pekaj 2018-10-10 16:05:14 +11:00
parent c3ce372f9f
commit c652ac40e2
3 changed files with 30 additions and 51 deletions

View File

@ -867,3 +867,9 @@ stock ArePlayersInHouse( houseid, owner )
} }
return false; 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 ];
}

View File

@ -566,3 +566,9 @@ stock GetGarageInteriorID( garageid ) {
stock GetGarageVirtualWorld( garageid ) { stock GetGarageVirtualWorld( garageid ) {
return g_garageData[ garageid ] [ E_WORLD ]; 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 ];
}

View File

@ -17122,33 +17122,11 @@ stock isNotNearPlayer( playerid, nearid, Float: distance = 200.0 )
return 1; return 1;
new new
Float: fDistance = 9999.9, Float: X, Float: Y, Float: Z;
Float: X, Float: Y, Float: Z,
// Get kidnapper data GetPlayerOutsidePos( nearid, X, Y, Z );
iEntrance = p_LastEnteredEntrance[ nearid ],
iHouse = p_InHouse[ nearid ],
iGarage = p_InGarage[ nearid ]
;
GetPlayerPos( nearid, X, Y, Z ); return GetPlayerDistanceFromPoint( playerid, X, Y, Z ) > distance ? 1 : 0;
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;
} }
stock GetVehicleDriver( vehicleid ) stock GetVehicleDriver( vehicleid )
@ -17208,23 +17186,12 @@ stock IsDeathmatchProtectedZone( playerid ) {
return false; return false;
}*/ }*/
stock GetPlayerLocation( iPlayer, szCity[ ], szLocation[ ] ) { stock GetPlayerLocation( iPlayer, szCity[ ], szLocation[ ] )
{
static static
Float: X, Float: Y, Float: Z; Float: X, Float: Y, Float: Z;
if ( GetPlayerInterior( iPlayer ) != 0 || IsPlayerInBank( iPlayer ) ) { GetPlayerOutsidePos( iPlayer, X, Y, Z );
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 );
Get2DCity( szCity, X, Y, Z ); Get2DCity( szCity, X, Y, Z );
GetZoneFromCoordinates( szLocation, X, Y, Z ); GetZoneFromCoordinates( szLocation, X, Y, Z );
@ -19113,24 +19080,24 @@ stock SendClientMessageToCops( colour, format[ ], va_args<> ) // Conversion to f
return 1; 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 new
iEntrance = p_LastEnteredEntrance[ playerid ], entranceid = p_LastEnteredEntrance[ playerid ],
iHouse = p_InHouse[ playerid ], houseid = p_InHouse[ playerid ],
iGarage = p_InGarage[ playerid ] garageid = p_InGarage[ playerid ]
; ;
if ( GetPlayerInterior( playerid ) != 0 ) if ( GetPlayerInterior( playerid ) != 0 || IsPlayerInBank( playerid ) )
{ {
if ( iEntrance != -1 ) if ( entranceid != -1 )
GetEntrancePos( iEntrance, X, Y, Z ); GetEntrancePos( entranceid, X, Y, Z );
else if ( iGarage != -1 ) else if ( garageid != -1 )
X = g_garageData[ iGarage ] [ E_X ], Y = g_garageData[ iGarage ] [ E_Y ], Z = g_garageData[ iGarage ] [ E_Z ]; GetGaragePos( garageid, X, Y, Z );
else if ( iHouse != -1 ) else if ( houseid != -1 )
X = g_houseData[ iHouse ] [ E_EX ], Y = g_houseData[ iHouse ] [ E_EY ], Z = g_houseData[ iHouse ] [ E_EZ ]; GetHousePos( houseid, X, Y, Z );
else GetPlayerPos( playerid, X, Y, Z ); else GetPlayerPos( playerid, X, Y, Z );
} }