does not slow down the vehicle -____-
#1

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!!!!
Reply
#2

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;
}
Reply
#3

that slows that a vehicle by 1 mile?
Reply
#4

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
Reply
#5

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

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.
Reply
#7

nope does not work^
-_-
please help
Reply
#8

Why u don't use floataround .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)