Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**['Скоростной' инклуд ;) ]**
- * Автор: Frog163 ***
- * Релиз: 12/04/2012 ***
- ******************************/
- #if defined _fspeed
- #endinput
- #endif
- #define _fspeed
- /*
- fGetPlayerSpeed(int player[, bool return_km=true])
- вернет скорость игрока в км/ч, если return_km=false то в mph
- fGetVehicleSpeed(int vehicle[, bool return_km=true])
- вернет скорость машины в км/ч, если return_km=false то в mph
- sSetVehicleSpeed(int vehicle, int speed)
- установит машине(vehicle) скорость: speed км/ч
- (не учитывает ротацию)
- fSetVehicleSpeed(int vehicle, int speed[, bool convert_km=true])
- установит машине(vehicle) скорость: speed км/ч
- если return_km=false то в mph
- (учитывает ротацию)
- fSetVehicleBoost(int vehicle[, int boost = 50[, int max_speed = 400[, bool convert_km = true]]])
- ускорит машину(vehicle) на 50 км/ч, при этом скорость не привысит 400 км/ч
- если return_km=false то скорость указывается в mph
- (учитывает ротацию)
- */
- stock fGetPlayerSpeed(player, bool:return_km=true){//by Frog163
- new Float:x, Float:y, Float:z;
- GetPlayerVelocity(player, x, y, z);
- return return_km?floatround(floatsqroot(x*x+y*y+z*z)*200):floatround(floatsqroot(x*x+y*y+z*z)*123.5);
- }
- stock fGetVehicleSpeed(vehicle, bool:return_km=true){//by Frog163
- new Float:x, Float:y, Float:z;
- GetVehicleVelocity(vehicle, x, y, z);
- return return_km?floatround(floatsqroot(x*x+y*y+z*z)*200):floatround(floatsqroot(x*x+y*y+z*z)*123.5);
- }
- stock sSetVehicleSpeed(vehicle, speed){//by Frog163
- new Float:sx, Float:sy, Float:sa;
- GetVehicleZAngle(vehicle, sa);
- sx = speed/200.0 * floatsin(-sa, degrees);
- sy = speed/200.0 * floatcos(-sa, degrees);
- return SetVehicleVelocity(vehicle, sx, sy, 0.0);
- }
- stock fSetVehicleSpeed(vehicle, speed, bool:convert_km=true){//by Frog163
- if(!speed)return SetVehicleVelocity(vehicle, 0.0, 0.0, 0.0);
- new Float:sx, Float:sy, Float:sz, Float:smode;
- if(convert_km)smode=200.0;
- else smode=123.5;
- new Float:invector[3] = {0.0, -1.0, 0.0};
- RotatePointVehicleRotation(vehicle, invector, sx, sy, sz);
- new Float:fk = floatabs(float(speed)/smode);
- return speed<0?SetVehicleVelocity(vehicle, -sx*fk, -sy*fk, -sz*fk):SetVehicleVelocity(vehicle, sx*fk, sy*fk, sz*fk);
- }
- stock fSetVehicleBoost(vehicle, boost=50, max_speed = 400, bool:convert_km=true){//by Frog163
- new Float:sx,Float:sy,Float:sz, Float:speed, Float:smode;
- if(convert_km)smode=200.0;
- else smode=123.5;
- GetVehicleVelocity(vehicle, sx, sy, sz);
- speed=floatsqroot(sx*sx+sy*sy+sz*sz)*smode;
- if(speed+boost < max_speed)speed += boost;
- else if(speed < max_speed)speed = max_speed;
- new Float:invector[3] = {0.0, -1.0, 0.0};
- RotatePointVehicleRotation(vehicle, invector, sx, sy, sz);
- new Float:fk = floatabs(float(speed)/smode);
- SetVehicleVelocity(vehicle, sx*speed, sy*speed, sz*speed);
- return true;
- }
- stock MatrixTransformVector(Float:vector[3], Float:m[4][4], &Float:resx, &Float:resy, &Float:resz){//by JernejL
- resz = vector[2] * m[0][0] + vector[1] * m[0][1] + vector[0] * m[0][2] + m[0][3];
- resy = vector[2] * m[1][0] + vector[1] * m[1][1] + vector[0] * m[1][2] + m[1][3];
- resx = -(vector[2] * m[2][0] + vector[1] * m[2][1] + vector[0] * m[2][2] + m[2][3]);// don't ask why -x was needed, i don't know either.
- }
- stock RotatePointVehicleRotation(vehid, Float:Invector[3], &Float:resx, &Float:resy, &Float:resz, worldspace=0){//by JernejL
- new Float:Quaternion[4];
- new Float:transformationmatrix[4][4];
- GetVehicleRotationQuat(vehid, Quaternion[0], Quaternion[1], Quaternion[2], Quaternion[3]);
- // build a transformation matrix out of the quaternion
- new Float:xx = Quaternion[0] * Quaternion[0];
- new Float:xy = Quaternion[0] * Quaternion[1];
- new Float:xz = Quaternion[0] * Quaternion[2];
- new Float:xw = Quaternion[0] * Quaternion[3];
- new Float:yy = Quaternion[1] * Quaternion[1];
- new Float:yz = Quaternion[1] * Quaternion[2];
- new Float:yw = Quaternion[1] * Quaternion[3];
- new Float:zz = Quaternion[2] * Quaternion[2];
- new Float:zw = Quaternion[2] * Quaternion[3];
- transformationmatrix[0][0] = 1 - 2 * ( yy + zz );
- transformationmatrix[0][1] = 2 * ( xy - zw );
- transformationmatrix[0][2] = 2 * ( xz + yw );
- transformationmatrix[0][3] = 0.0;
- transformationmatrix[1][0] = 2 * ( xy + zw );
- transformationmatrix[1][1] = 1 - 2 * ( xx + zz );
- transformationmatrix[1][2] = 2 * ( yz - xw );
- transformationmatrix[1][3] = 0.0;
- transformationmatrix[2][0] = 2 * ( xz - yw );
- transformationmatrix[2][1] = 2 * ( yz + xw );
- transformationmatrix[2][2] = 1 - 2 * ( xx + yy );
- transformationmatrix[2][3] = 0;
- transformationmatrix[3][0] = 0;
- transformationmatrix[3][1] = 0;
- transformationmatrix[3][2] = 0;
- transformationmatrix[3][3] = 1;
- // transform the point thru car's rotation
- MatrixTransformVector(Invector, transformationmatrix, resx, resy, resz);
- // if worldspace is set it'll return the coords in global space - useful to check tire coords against tire spike proximity directly, etc..
- if (worldspace == 1){
- new Float:fX, Float:fY, Float:fZ;
- GetVehiclePos(vehid, fX, fY, fZ);
- resx += fX;
- resy += fY;
- resz += fZ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement