#1

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

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(playeridvX*numbervY*number vZ*number); 
Reply
#3

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

Thanks, but now it doesn't work in vehicle
Reply
#5

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

thanks! +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)