Interior check, vehicle id validation
This commit is contained in:
parent
bb530eb1c9
commit
406d705ae1
@ -196,6 +196,7 @@ CMD:gps( playerid, params[ ] )
|
|||||||
return SendServerMessage( playerid, "You have de-activated your GPS." ), 1;
|
return SendServerMessage( playerid, "You have de-activated your GPS." ), 1;
|
||||||
}
|
}
|
||||||
else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You have to be a driver of a vehicle to use this a command." );
|
else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You have to be a driver of a vehicle to use this a command." );
|
||||||
|
else if ( GetPlayerInterior( playerid ) != 0 ) return SendError( playerid, "You must be outside of the interior." );
|
||||||
else if( !strcmp( params, "atm", false, 3 ) ) {
|
else if( !strcmp( params, "atm", false, 3 ) ) {
|
||||||
new Float: oX, Float: oY, Float: oZ;
|
new Float: oX, Float: oY, Float: oZ;
|
||||||
new atmID = GetClosestATM( playerid );
|
new atmID = GetClosestATM( playerid );
|
||||||
@ -208,9 +209,12 @@ CMD:gps( playerid, params[ ] )
|
|||||||
if ( sscanf( params[ 8 ], "s[24]", vehName ) ) return SendUsage( playerid, "/gps vehicle [NAME]" );
|
if ( sscanf( params[ 8 ], "s[24]", vehName ) ) return SendUsage( playerid, "/gps vehicle [NAME]" );
|
||||||
|
|
||||||
new Float: vXp, Float: vYp, Float: vZp, vehID = GetVehicleModelFromName( vehName );
|
new Float: vXp, Float: vYp, Float: vZp, vehID = GetVehicleModelFromName( vehName );
|
||||||
|
|
||||||
|
if( vehID == -1 ) return SendError( playerid, "Invalid vehicle name." );
|
||||||
|
|
||||||
GetVehiclePos( GetClosestVehicleModel( playerid, vehID ), vXp, vYp, vZp );
|
GetVehiclePos( GetClosestVehicleModel( playerid, vehID ), vXp, vYp, vZp );
|
||||||
|
|
||||||
SendClientMessageFormatted( playerid, -1, ""COL_GREY"[GPS]"COL_WHITE" You have set your destination to closest vehicle (model %d)", vehID );
|
SendClientMessageFormatted( playerid, -1, ""COL_GREY"[GPS]"COL_WHITE" You have set your destination to closest %s", GetVehicleName( vehID ) );
|
||||||
|
|
||||||
GPS_SetPlayerWaypoint( playerid, "Closest vehicle (model)", vXp, vYp, vZp );
|
GPS_SetPlayerWaypoint( playerid, "Closest vehicle (model)", vXp, vYp, vZp );
|
||||||
}
|
}
|
||||||
@ -301,20 +305,6 @@ function GPS_Update( playerid, Float: destX, Float: destY, Float: destZ )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
stock GetClosestATM( playerid ){
|
|
||||||
new closest = -1, Float: closestDist = 8000.00, Float: distance, Float: pX, Float: pY, Float: pZ, Float: oX, Float: oY, Float: oZ;
|
|
||||||
for(new i = 0; i < MAX_ATMS; i++){
|
|
||||||
GetATMPos( i, oX, oY, oZ );
|
|
||||||
GetPlayerPos( playerid, pX, pY, pZ );
|
|
||||||
distance = floatsqroot( ( (pX - oX) * (pX - oX) ) + ( (pY - oY) * (pY - oY) + ( (pZ - oZ) * (pZ - oZ) ) ) );
|
|
||||||
if( closestDist > distance ){
|
|
||||||
closestDist = distance;
|
|
||||||
closest = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return closest;
|
|
||||||
}
|
|
||||||
|
|
||||||
stock GetClosestVehicleModel( playerid, id ){
|
stock GetClosestVehicleModel( playerid, id ){
|
||||||
new closest = -1, Float: closestDist = 8000.00, Float: distance, Float: pX, Float: pY, Float: pZ;
|
new closest = -1, Float: closestDist = 8000.00, Float: distance, Float: pX, Float: pY, Float: pZ;
|
||||||
for(new i = 0; i < MAX_VEHICLES; i++){
|
for(new i = 0; i < MAX_VEHICLES; i++){
|
||||||
|
@ -240,6 +240,20 @@ stock CreateATM( Float: X, Float: Y, Float: Z, Float: rX, Float: offset = 180.0,
|
|||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock GetClosestATM( playerid ){
|
||||||
|
new closest = -1, Float: closestDist = 8000.00, Float: distance, Float: pX, Float: pY, Float: pZ, Float: oX, Float: oY, Float: oZ;
|
||||||
|
for(new i = 0; i < MAX_ATMS; i++){
|
||||||
|
GetATMPos( i, oX, oY, oZ );
|
||||||
|
GetPlayerPos( playerid, pX, pY, pZ );
|
||||||
|
distance = floatsqroot( ( (pX - oX) * (pX - oX) ) + ( (pY - oY) * (pY - oY) + ( (pZ - oZ) * (pZ - oZ) ) ) );
|
||||||
|
if( closestDist > distance ){
|
||||||
|
closestDist = distance;
|
||||||
|
closest = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return closest;
|
||||||
|
}
|
||||||
|
|
||||||
stock GetATMPos( atmID, &Float: X, &Float: Y, &Float: Z ) {
|
stock GetATMPos( atmID, &Float: X, &Float: Y, &Float: Z ) {
|
||||||
return GetDynamicObjectPos( g_atmData[ atmID ] [ E_OBJECT ], X, Y, Z );
|
return GetDynamicObjectPos( g_atmData[ atmID ] [ E_OBJECT ], X, Y, Z );
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user