SA-MP Forums Archive
[Help] Flip - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help] Flip (/showthread.php?tid=353869)



[Help] Flip w/ Image - kbalor - 24.06.2012

This is the normal flip command that flips your car.

Quote:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys & KEY_HORN)
{
if(IsPlayerInAnyVehicle(playerid))
{
new VehicleID,Float:B;
VehicleID = GetPlayerVehicleID(playerid);
GetVehicleZAngle(VehicleID,B);
SetVehicleZAngle(VehicleID,B);
}
}
return 1;
}

Can anyone add a script that when, vehicle flip it stops moving at current angel. Coz sometimes when I use boost it takes me very fast somewhere and after i press H. It just flip and still moving fast.


Re: [Help] Flip - JaTochNietDan - 24.06.2012

Simply use SetVehicleVelocity, for example:

pawn Код:
SetVehicleVelocity(vehicleid, 0.0, 0.0, 0.0);
The vehicle should then stop.


Re: [Help] Flip - Grand_Micha - 24.06.2012

Under SetVehicleZAngle, add this line:

SetVehicleVelocity(VehicleID,0,0,0);


Re: [Help] Flip - kbalor - 24.06.2012

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Simply use SetVehicleVelocity, for example:

pawn Код:
SetVehicleVelocity(vehicleid, 0.0, 0.0, 0.0);
The vehicle should then stop.
it works but whenever i hit something and my vehicle rotates it just stop, but my car still rotating i mean rolling.. any solution how to Stop the car from rotating..


Re: [Help] Flip - Grand_Micha - 24.06.2012

Then add this, too:

SetVehicleAngularVelocity(VehicleID,0,0,0);


Re: [Help] Flip - kbalor - 24.06.2012

Quote:
Originally Posted by Grand_Micha
Посмотреть сообщение
Under SetVehicleZAngle, add this line:

SetVehicleVelocity(VehicleID,0,0,0);
But after i hit something and my vehicle rotates after i press H it flips but still rotating(rolling)..


Re: [Help] Flip - JaTochNietDan - 24.06.2012

Quote:
Originally Posted by kbalor
Посмотреть сообщение
But after i hit something and my vehicle rotates after i press H it flips but still rotating(rolling)..
Read his second reply, he suggests using SetVehicleAngularVelocity.


Re: [Help] Flip - kbalor - 24.06.2012

Quote:
Originally Posted by Grand_Micha
Посмотреть сообщение
Then add this, too:

SetVehicleAngularVelocity(VehicleID,0,0,0);
well done! thanks can i have my last request for this day??

I need a fly script for vehicle again. Sometimes when my vehicle get stuck in a object or building. If I press Y for fly key. It moves a little bit but still stuck. How can my vehicle pass though fast so it may not take time to get unstuck on a spot?


Re: [Help] Flip - Grand_Micha - 24.06.2012

Код:
stock SetVehicleForwardVelocity(playerid,Float:Velocity, Float:Z1)
{
new Float:Getx1, Float:Gety1, Float:Getz1;
new Float:AngleZ1;
new Float:SpeedX1, Float:SpeedY1;
new Float:Mulx1, Float:Muly1;
new Vehicle = GetPlayerVehicleID(playerid);
GetVehicleVelocity(Vehicle, Getx1 ,Gety1 ,Getz1);
GetVehicleZAngle(Vehicle,AngleZ1);
SpeedX1 = floatsin(-AngleZ1, degrees);
SpeedY1 = floatcos(-AngleZ1, degrees);
Mulx1 = floatmul(Velocity, SpeedX1);
Muly1 = floatmul(Velocity, SpeedY1);
SetVehicleVelocity(Vehicle, floatadd(Mulx1,Getx1), floatadd(Muly1, Gety1), floatadd(Getz1, Z1));
return 1;
}
This is not really for flying, but it is a combination of jumping and boosting.


Re: [Help] Flip - kbalor - 24.06.2012

Quote:
Originally Posted by Grand_Micha
Посмотреть сообщение
Код:
stock SetVehicleForwardVelocity(playerid,Float:Velocity, Float:Z1)
{
new Float:Getx1, Float:Gety1, Float:Getz1;
new Float:AngleZ1;
new Float:SpeedX1, Float:SpeedY1;
new Float:Mulx1, Float:Muly1;
new Vehicle = GetPlayerVehicleID(playerid);
GetVehicleVelocity(Vehicle, Getx1 ,Gety1 ,Getz1);
GetVehicleZAngle(Vehicle,AngleZ1);
SpeedX1 = floatsin(-AngleZ1, degrees);
SpeedY1 = floatcos(-AngleZ1, degrees);
Mulx1 = floatmul(Velocity, SpeedX1);
Muly1 = floatmul(Velocity, SpeedY1);
SetVehicleVelocity(Vehicle, floatadd(Mulx1,Getx1), floatadd(Muly1, Gety1), floatadd(Getz1, Z1));
return 1;
}
This is not really for flying, but it is a combination of jumping and boosting.
What the key to fly? or is there any?

P.S some server using fly script that can passed through wall. just like jump script..