SA-MP Forums Archive
SetPlayerVelocity question - 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: SetPlayerVelocity question (/showthread.php?tid=304624)



SetPlayerVelocity question [Rep+] - Celson - 19.12.2011

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?


Re: SetPlayerVelocity question - Celson - 03.01.2012

Still need help with this. Offering Rep +


Re: SetPlayerVelocity question - Celson - 06.01.2012

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?


Re: SetPlayerVelocity question - Celson - 10.01.2012

Bump.


Re: SetPlayerVelocity question - T0pAz - 10.01.2012

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


Re: SetPlayerVelocity question - Shadoww5 - 10.01.2012

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



Re: SetPlayerVelocity question - Celson - 11.01.2012

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.


Re: SetPlayerVelocity question - Snowman12 - 11.01.2012

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


Re: SetPlayerVelocity question - Celson - 11.01.2012

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.


Re: SetPlayerVelocity question - Snowman12 - 11.01.2012

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