[FilterScript] Speed Boost + Jump Car
#17

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
So, what you want to listen is "thanks", "great fs", "nice work" and get reputation. Ok man, I've nothing to do here, since you can't hear constructive criticism about your scripts.
And a correction: I said: "maybe I've more experience than you", not "Ive more experience than you". Respect, man.

Just to finalize, even if you care or not, and because probably others care, here there's a simple FS to Speed Boost and Car Jump:

Код:
#include <a_samp>
#include <sscanf2> 
#include <zcmd> //I'm using these includes to avoid old functions and make it simple

new Float: SpeedBoostMultiplier[MAX_PLAYERS];
new Float: JumpSize[MAX_PLAYERS]; //variable to configure, activate or deactivate car jump

public OnPlayerConnect(playerid)
{
	SpeedBoostMultiplier[playerid] = 1.5;
	JumpSize[playerid] = 0.2;
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys & KEY_ACTION) //CTRL to speed boost
	{
	    if(SpeedBoostMultiplier[playerid] == 0) return 1;
            if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
	    new Float:currspeed[3], Float:direction[3], Float:total;
	    GetVehicleVelocity(GetPlayerVehicleID(playerid), currspeed[0], currspeed[1], currspeed[2]);
	    total = floatsqroot((currspeed[0] * currspeed[0]) + (currspeed[1] * currspeed[1]) + (currspeed[2] * currspeed[2]));
	    total += 0.7;
	    new Float:invector[3] = {0.0, -1.0, 0.0};
	    RotatePointVehicleRotation(GetPlayerVehicleID(playerid), invector, direction[0], direction[1], direction[2]);
	    SetVehicleVelocity(GetPlayerVehicleID(playerid),
		direction[0] * total * SpeedBoostMultiplier[playerid],
		direction[1] * total * SpeedBoostMultiplier[playerid],
		direction[2] * total * SpeedBoostMultiplier[playerid]); //I added here a boost factor to increase or decrese boost power.

             //Note: Like Matite, you could still use this code to avoid abuses:
	   //if (floatabs(currspeed[ 0 ]) < 3 && floatabs(currspeed[ 1 ]) < 3 && floatabs(currspeed[ 2 ]) < 3)
        }

	if(newkeys & KEY_CROUCH) //H to make car jump
	{
	        if(JumpSize[playerid] == 0) return 1;
		if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
		new Float: x, Float: y, Float: z;
		GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
                SetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z + JumpSize[playerid]); //The same here.
	}
        return 1;
}

//Command to activate or deactivate boost, with an extra function: configure boost factor. With "factor" I mean "power"
CMD:boost(playerid, params[])
{
	new Float: value;
	if(!sscanf(params, "f", value)) //if player type some parameter, we configure the boost factor and automatically active it.
	{
		if(value < 1.0 || value > 3.0) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /boost <1.0-3.0>");
		SpeedBoostMultiplier[playerid] = value;
		new msg[64];
		format(msg, 64, "You have a new speed boost factor: %.2f! Press CTRL to use it!", value);
		SendClientMessage(playerid, 0xFFFFFFFF, msg);
	}
	else //otherwise, we activate or deactivate the boost.
 	{
	 	if(SpeedBoostMultiplier[playerid] == 0)
	 	{
                        SpeedBoostMultiplier[playerid] = 1.5;
                        SendClientMessage(playerid, 0xFFFFFFFF, "You turned on the speed boost multiplier. Press CTRL to use it. Type /boost <1.0-3.0> to configure it!");
		}
		else
		{
			SpeedBoostMultiplier[playerid] = 0;
			SendClientMessage(playerid, 0xFFFFFFFF, "You turned off the speed boost multiplier. Type /boost to activate it again!");
		}
 	}
	return 1;
}

//Extra command I added to the configure jump size - note that this command is very similar to the /boost one.
CMD:jump(playerid, params[])
{
	new Float: value;
	if(!sscanf(params, "f", value))
	{
		if(value < 0.1 || value > 10.0) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /jump <0.1-10.0>"); //Use reasonable values
		JumpSize[playerid] = value;
		new msg[64];
		format(msg, 64, "You have a new jump size: %.2f! Press H to use it!", value);
		SendClientMessage(playerid, 0xFFFFFFFF, msg);
	}
	else
 	{
	 	if(JumpSize[playerid] == 0)
	 	{
                        JumpSize[playerid] = 0.2; //reasonable car jump
                        SendClientMessage(playerid, 0xFFFFFFFF, "You turned on the jump car mode. Press H to use it. Type /jump <0.1-1.0> to configure it!");
		}
		else
		{
			JumpSize[playerid] = 0;
			SendClientMessage(playerid, 0xFFFFFFFF, "You turned off the jump car mode. Type /jump to activate it again!");
		}
 	}
	return 1;
}

//From the tutorial by The_Gangstas I told you:
stock MatrixTransformVector(Float:vector[3], Float:m[4][4], &Float:resx, &Float:resy, &Float:resz) {
        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)
{
    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;
    }
}
ok

Quote:
Originally Posted by David Shelby™
Посмотреть сообщение
Cool Nice work
Thanks
Reply


Messages In This Thread
Speed Boost + Jump Car - by Aloushi - 27.04.2012, 09:21
Re: Speed Boost + Jump Car - by RollTi - 27.04.2012, 09:33
Re: Speed Boost + Jump Car - by Aloushi - 27.04.2012, 09:38
AW: Speed Boost + Jump Car - by Pablo Borsellino - 27.04.2012, 10:20
Re: AW: Speed Boost + Jump Car - by Aloushi - 27.04.2012, 10:56
Re: Speed Boost + Jump Car - by Youice - 27.04.2012, 11:02
Re: Speed Boost + Jump Car - by Waw - 27.04.2012, 11:32
Re: Speed Boost + Jump Car - by Youice - 27.04.2012, 11:38
Re: Speed Boost + Jump Car - by Aloushi - 27.04.2012, 16:37
Re: Speed Boost + Jump Car - by denNorske - 09.05.2012, 20:23
Re: Speed Boost + Jump Car - by richardcor91 - 10.05.2012, 03:24
Re: Speed Boost + Jump Car - by Aloushi - 10.05.2012, 14:28
Re: Speed Boost + Jump Car - by richardcor91 - 10.05.2012, 14:59
Re: Speed Boost + Jump Car - by Aloushi - 10.05.2012, 21:49
Re: Speed Boost + Jump Car - by richardcor91 - 11.05.2012, 00:01
Re: Speed Boost + Jump Car - by David Shelby™ - 11.05.2012, 05:03
Re: Speed Boost + Jump Car - by Aloushi - 11.05.2012, 12:33
Re: Speed Boost + Jump Car - by Devilxz97 - 13.05.2012, 12:45
Re: Speed Boost + Jump Car - by HaZaRaS™ - 13.05.2012, 12:53
Re: Speed Boost + Jump Car - by Aloushi - 18.05.2012, 22:13
Re: Speed Boost + Jump Car - by isheremse - 28.05.2012, 14:30
Re: Speed Boost + Jump Car - by Aloushi - 28.05.2012, 15:25
Re: Speed Boost + Jump Car - by Dasine94 - 13.07.2012, 14:57
Re: Speed Boost + Jump Car - by Aloushi - 14.07.2012, 17:15
Re: Speed Boost + Jump Car - by cowmilker69 - 16.07.2013, 20:20
Re: Speed Boost + Jump Car - by SadGasm - 24.07.2013, 14:41
Re: Speed Boost + Jump Car - by Insulin - 24.07.2013, 15:06
Re: Speed Boost + Jump Car - by azlaoui - 27.07.2014, 14:01
Re: Speed Boost + Jump Car - by SHE790 - 27.07.2014, 14:06

Forum Jump:


Users browsing this thread: 1 Guest(s)