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: speed (
/showthread.php?tid=656680)
speed boost help -
Heress - 21.07.2018
Hello, I try to do a speed boost to the forward with car.
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_CTRL_BACK)
{
if(IsPlayerInAnyVehicle(playerid))
{
new Float: vX, Float: vY, Float: vZ;
GetPlayerVelocity(playerid, vX, vY, vZ);
SetPlayerVelocity(playerid, vX + 5.0, vY , vZ);
}
}
return 1;
}
This Boost works just in x coordinate, but I want what ot work to the forward of player. How I can change direction?
Sorry for my bad english
Re: speed -
coool - 21.07.2018
It will only work in X direction because you are doing "SetPlayerVelocity(playerid, vX + 5.0, vY , vZ);"
Instead of using multiplication in all directions.
PHP код:
SetPlayerVelocity(playerid, vX*number, vY*number , vZ*number);
Re: speed -
Sew_Sumi - 21.07.2018
https://sampwiki.blast.hk/wiki/OnPlayerK...heck_for_a_key
Quote:
|
Originally Posted by wiki
Let's presume that you want to detect when a player presses their FIRE button, the obvious code would be:
PHP код:
if (newkeys == KEY_FIRE)
This code may even work in your testing, but it is wrong and your testing is insufficient. Try crouching and pressing fire - your code will instantly stop working. Why? Because "newkeys" is no longer the same as "KEY_FIRE", it is the same as "KEY_FIRE" COMBINED WITH "KEY_CROUCH".
|
Re: speed -
Heress - 21.07.2018
Thanks, but now it doesn't work in vehicle
Re: speed -
Sew_Sumi - 21.07.2018
You also need more than just to add speed to a vector, you need to do some calculations and such.
This guy made a filterscript doing pretty much what you want.
https://sampforum.blast.hk/showthread.php?tid=337636
Re: speed -
Heress - 21.07.2018
thanks!

+rep