[Include] [INC] USEFUL: Forward velocity...
#1

Hi. I made these two functions, because I was bored...

SetPlayerForwardVelocity(playerid, Float:Velocity, Float:Z);
Set some forward velocity to player.

SetVehicleForwardVelocity(vehicleid, Float:Velocity, Float:Z);
No comment.

Here they are:
pawn Код:
stock bool:SetPlayerForwardVelocity(playerid, Float:Velocity, Float:Z)
{
if(!IsPlayerConnected(playerid)) return false;
new Float:Angle;
new Float:SpeedX, Float:SpeedY;
GetPlayerFacingAngle(playerid, Angle);
SpeedX = floatsin(-Angle, degrees);
SpeedY = floatcos(-Angle, degrees);
SetPlayerVelocity(playerid, floatmul(Velocity, SpeedX), floatmul(Velocity, SpeedY), Z);
return true;
}

stock bool:SetVehicleForwardVelocity(vehicleid, Float:Velocity, Float:Z)
{
new Float:Angle;
new Float:SpeedX, Float:SpeedY;
GetVehicleZAngle(vehicleid, Angle);
SpeedX = floatsin(-Angle, degrees);
SpeedY = floatcos(-Angle, degrees);
SetVehicleVelocity(vehicleid, floatmul(Velocity, SpeedX), floatmul(Velocity, SpeedY), Z);
return true;
}
CREDITS: Someone who have made GetXYInFrontOfPlayer... It helped me a lot. And Kurence for an idea...
I hope you like them... Have a lot of fun!
Reply


Messages In This Thread
[INC] USEFUL: Forward velocity... - by ¤Adas¤ - 21.01.2010, 18:56
Re: [INC] USEFUL: Forward velocity... - by Kurence - 22.01.2010, 13:39

Forum Jump:


Users browsing this thread: 1 Guest(s)