SA-MP Forums Archive
Increasing vehicle's speed. - 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: Increasing vehicle's speed. (/showthread.php?tid=505828)



Increasing vehicle's speed. - VerticalGaming - 10.04.2014

Hello,
Is it possible to edit a vehicle his speed?
For example.
Standard: Infernus goes 205km/h.
But can I let it go 400km/h?
If yes, how?


Re: Increasing vehicle's speed. - Bingo - 10.04.2014

Yes,

GetPlayerVelocity and SetPlayerVelocity.

Velocity = Speed


Re: Increasing vehicle's speed. - SyntaxQ - 10.04.2014

You can do that by adding nitro/speed boost..
Here is an example code to help you out:
pawn Код:
// OnPlayerKeyStateChange
if(newkeys & KEY_FIRE)
{
        if (IsPlayerInAnyVehicle(playerid))
        {
            new Float:vx, Float:vy, Float:vz;
            AddVehicleComponent(GetPlayerVehicleID(playerid), 1010); // Ignore this line if you don't want the nitro component to appear..
            GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
            SetVehicleVelocity(GetPlayerVehicleID(playerid) ,vx * 1.5,vy * 1.5 ,vz * 1.5);
        }
}



Re: Increasing vehicle's speed. - RajatPawar - 10.04.2014

Quote:
Originally Posted by [vTc]Patroool
Посмотреть сообщение
Yes,

GetPlayerVelocity and SetPlayerVelocity.

Velocity = Speed
Being a science student, I can't ignore that comment. Sorry for the nerdiness, but velocity is a vector, speed's not. The correct statement is -

Velocity = | speed |

where ' | ' represents the magnitude

:facepalm:


Re: Increasing vehicle's speed. - Bingo - 10.04.2014

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Being a science student, I can't ignore that comment. Sorry for the nerdiness, but velocity is a vector, speed's not. The correct statement is -

Velocity = | speed |

where ' | ' represents the magnitude

:facepalm:
Acha :P Nerd.

Тhank you for this :P.


Re: Increasing vehicle's speed. - VerticalGaming - 10.04.2014

I've checked the velocity.
When driving 83km/h (Max speed, and shown like this on the speedometer).
I got this data:
X: -0.516280
Y: 0.017158
Z: 0.000001

Now, How can I make it like, the kart (vehicle name: kart[0]) will maximum drive 30km/h.
kart[1] maximum 50km/h
& kart[3] will be speeded up to 400km/h.

Kind regards, VerticalGaming.


Re: Increasing vehicle's speed. - Konstantinos - 10.04.2014

https://sampforum.blast.hk/showthread.php?tid=179089


Re: Increasing vehicle's speed. - VerticalGaming - 10.04.2014

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Merged the filterscript in the gamemode.
Anyways.

Now I've this.
pawn Код:
public OnPlayerEnterVehicle( playerid, vehicleid, ispassenger )
{
    if ( vehicleid == kart[0] || vehicleid == kart[1]){SetPlayerSpeedCap( playerid, 0.4 );}
    else if ( vehicleid == kart[2] || vehicleid == kart[3] || vehicleid == kart[4] || vehicleid == kart[5] || vehicleid == kart[6] || vehicleid == kart[7])
    {
    SetPlayerSpeedCap( playerid, 0.4 );
    }
    else DisablePlayerSpeedCap( playerid );
}
How to calculate the amount?

If MAX SPEED = 100
And Speedcap = 0.1
The max speed will be 10?
Or something else? :/


Re: Increasing vehicle's speed. - Konstantinos - 10.04.2014

According to Slice:
Quote:
Originally Posted by Slice
An example of a value that feels like 50 km/h is 0.3
So do the maths:

50 0.3
100 x

...

x = 0.6


Re: Increasing vehicle's speed. - VerticalGaming - 10.04.2014

50 x 0.3
0.3 / 50 = 0,006
So 30 km = 0.18?

EDIT;
Got it working.
Perfect.

Now, how can I make a vehicle going faster?