SetPlayerVelocity question
#1

How can I make the player jump in the direction he's facing using SetPlayerVelocity?

I tried using this code

pawn Код:
new Float:X,Float:Y;
GetXYInFrontOfPlayer(playerid,X,Y,2.0);
SetPlayerVelocity(playerid,X,Y,0.2);
But that didn't really work anything like I had expected it too...

Ideas?
Reply
#2

Still need help with this. Offering Rep +
Reply
#3

Bump. Still need help with this. I've seen this sorta stuff on basically every popular stunt server. Isn't there like some sorta maths formula for this?
Reply
#4

Bump.
Reply
#5

First of all get his facing angle using GetPlayerFacingAngle and then use SetPlayerFacingAngle.
Reply
#6

PHP код:
new Float:pxFloat:pyFloat:pz;
GetXYZInFrontOfPlayer(playeridpxpypz6.0);
SafeSetPlayerPos(playeridpxpypz+5); 
Reply
#7

Quote:
Originally Posted by Shadoww5
Посмотреть сообщение
PHP код:
new Float:pxFloat:pyFloat:pz;
GetXYZInFrontOfPlayer(playeridpxpypz6.0);
SafeSetPlayerPos(playeridpxpypz+5); 
What is SafeSetPlayerPos? It's not a valid function.

All I really need is that mathematical formula used with SetPlayerVelocity or SetVehicleVelocity. It's often used in stunt servers where if a player presses the KEY_FIRE button it gives the car a speed boost. I'm wanting to do something similar to that but using SetPlayerVelocity.
Reply
#8

SafeSetPlayerPos is a function mostly found in anticheats; NOT what you need, you will be needing a function which you used above SetPlayerVelocity. Set it so the player moves in the direction you want etc.. if you want it on a key do
pawn Код:
/* OnPlayerKeyStateChange */
    if(newkeys == KEY_FIRE)
    {
    /* blahhh */
    }
How ever be sure to check if the player isn't sending any armed data other wise they will not be able to use weapons.. Another thing don't use this unless clearing you Anticheat first - if you have - Otherwise your player will end up banned :P. Alright;

Best of luck,

-Snowman
Reply
#9

Quote:
Originally Posted by Snowman12
Посмотреть сообщение
SafeSetPlayerPos is a function mostly found in anticheats; NOT what you need, you will be needing a function which you used above SetPlayerVelocity. Set it so the player moves in the direction you want etc.. if you want it on a key do
pawn Код:
/* OnPlayerKeyStateChange */
    if(newkeys == KEY_FIRE)
    {
    /* blahhh */
    }
How ever be sure to check if the player isn't sending any armed data other wise they will not be able to use weapons.. Another thing don't use this unless clearing you Anticheat first - if you have - Otherwise your player will end up banned :P. Alright;

Best of luck,

-Snowman
I appreciate the help. But it isn't doing me any good. SetPlayerVelocity is a bit more complicated than I originally thought. You can't just put in an X Y Z coordinate and the player will be pushed in that direction. It needs an X offset and a Y offset sort of thing. I can recall seeing the code used somewhere to calculate the proper X offset and Y offset from a X and Y coordinate.

So my problem is not a lack of scripting knowledge. It's just that I have no idea what the math formula is.
Reply
#10

Ohhh math I do not understand when it comes to scripting; sorry man.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)