I don't see how any of the code posted will help you avoid hitting objects.
You would need to loop through all objects that are close to the player, and make sure none of them are at jumping height. If they are don't allow the jump. This would be difficult because most objects are different sizes.
In fact i think the code above could spawn you inside some objects. I'd rather bounce off an object than risk getting stuck in one.
pawn Код:
if(IsPlayerInAnyVehicle(playerid))
{
new VehicleID,Float:B;
VehicleID = GetPlayerVehicleID(playerid);
GetVehicleZAngle(VehicleID,B);
SetVehicleZAngle(VehicleID,B);
SetVehicleVelocity(VehicleID, 0.0, 0.0, 0.2);
SetVehicleAngularVelocity(VehicleID,0,0,0);
}
^^ I don't think that will work as expected, that will stop the vehicle from moving in every direction except
z by 0.2. IMO car jumps should keep the car traveling. Also something pointless in the above code is getting the angle and setting it to the same value
Better version:
pawn Код:
new VehicleID = GetPlayerVehicleID(playerid);
if(VehicleID)
{
new Float:fVelocity[3];
GetVehicleVelocity(VehicleID, fVelocity[0], fVelocity[1], fVelocity[2]);
SetVehicleVelocity(VehicleID, fVelocity[0], fVelocity[1], fVelocity[2]+0.2);
}
EDIT: Something else i just thought of; you should add anti-abuse for car jumping, if you spam the jump button it will appear as if your flying.