SA-MP Forums Archive
[Include] [INC] USEFUL: Forward velocity... - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] [INC] USEFUL: Forward velocity... (/showthread.php?tid=122396)



[INC] USEFUL: Forward velocity... - ¤Adas¤ - 21.01.2010

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!



Re: [INC] USEFUL: Forward velocity... - Kurence - 22.01.2010

Horrible , and never try to log into my account!!!
Offtopic: muhaha good work