SA-MP Forums Archive
does not slow down the vehicle -____- - 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: does not slow down the vehicle -____- (/showthread.php?tid=460183)



does not slow down the vehicle -____- - SwisherSweet - 27.08.2013

so i have this stock which is not slowing down the vehicle -_-
Код:
stock SlowDownVehicle(mph)
{
	new Float:Vx,Float:Vy,Float:Vz,Float:DV,Float:multiple;
	for( new c = 1; c <= MAX_VEHICLES; c ++ )
	{
		GetVehicleVelocity(c,Vx,Vy,Vz);
		DV = floatsqroot(Vx*Vx + Vy*Vy + Vz*Vz);
		if(DV > 0)
		{
			multiple = ((mph + DV * 100) / (DV * 100));
			return SetVehicleVelocity(c,Vx*multiple,Vy*multiple,Vz*multiple);
		}
	}
	return 0;
}
it has no errors but the bug is that it is not slowing the vehicles!!!!


Re: does not slow down the vehicle -____- - Dragonsaurus - 27.08.2013

You can use the opposite of boost maybe?
pawn Код:
stock SlowDownVehicle(playerid) // You should include playerid here, not mph...
{
     new Float:vx,Float:vy,Float:vz;
     GetVehicleVelocity(GetPlayerVehicleID(playerid),vx,vy,vz);
     SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 0.8, vy *0.8, vz * 0.8);
     return 1;
}



Re: does not slow down the vehicle -____- - SwisherSweet - 27.08.2013

that slows that a vehicle by 1 mile?


Re: does not slow down the vehicle -____- - SwisherSweet - 27.08.2013

ok so this is my full code

Код:
forward RepeatEngineBreak();

SetTimer("RepeatEngineBreak", 500, 1);

public RepeatEngineBreak()
{
    SlowDownVehicle(-1);
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if ((oldkeys & KEY_SPRINT) && !(newkeys & KEY_SPRINT))
    {
		if(IsPlayerInAnyVehicle(playerid))
		{
			RepeatEngineBreak();
		}
	}
	return 1;
}


stock SlowDownVehicle(playerid)
{
     new Float:vx,Float:vy,Float:vz;
     GetVehicleVelocity(GetPlayerVehicleID(playerid),vx,vy,vz);
     SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 0.8, vy *0.8, vz * 0.8);
     return 1;
}
basically in this code it's supposed to keep slowing down the vehicle 1.0 mil every half a second but no luck


Re: does not slow down the vehicle -____- - Dragonsaurus - 27.08.2013

That slows down the vehicle by 80%.
Oh, I see, but this is too advanced for me, I can't help you... Sorry :/


Re: does not slow down the vehicle -____- - Konstantinos - 27.08.2013

The above code is really awful, not offence. The timer is not needed, you call the RepeatEngineBreak and when it is being called, it calls SlowDownVehicle with parameter -1 as playerid which is not valid.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if ((oldkeys & KEY_SPRINT) && !(newkeys & KEY_SPRINT))
    {
        if(IsPlayerInAnyVehicle(playerid)) SlowDownVehicle(playerid);
    }
    return 1;
}


stock SlowDownVehicle(playerid)
{
     new Float:vx,Float:vy,Float:vz;
     GetVehicleVelocity(GetPlayerVehicleID(playerid),vx,vy,vz);
     SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 0.8, vy *0.8, vz * 0.8);
     return 1;
}
Call it once and you're done. About the values now. I think that when you multiply with a number under 1, it either slows down or stops, I don't remember.


Re: does not slow down the vehicle -____- - SwisherSweet - 27.08.2013

nope does not work^
-_-
please help


Re: does not slow down the vehicle -____- - PrinceKumar - 27.08.2013

Why u don't use floataround .