Raised This Month: $51 Target: $400
 12% 

pev_velocity not working properly


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 09-03-2011 , 13:09   pev_velocity not working properly
Reply With Quote #1

I have been playing with pev_velocity and i noticed the that code below has an unsual bug:
Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> public plugin_init() {     register_plugin("[ZP] Jetpack", "1.0", "@bdul!")         RegisterHam(Ham_ObjectCaps, "player", "fw_PlayerUseAttempt", 1) } public fw_PlayerUseAttempt(id) {     static Float:velocity[3]     pev(id, pev_velocity, velocity)         velocity[2] += 40     set_pev(id, pev_velocity, velocity)     client_print(id, print_chat, "Your Velocity: %.1f %.1f %.1f ", velocity[0], velocity[1], velocity[2]) }
Now, this is a type of a Jetpack i have been working on, the problem is that when i press the use key, 40 units is added to my z velocity but it doesnt work and i remain on ground (instead of being lifted).

Also, the reading i m getting from client_print clearly shows that 40.0 units is being added to my velocity :S

However when i jump and then press the use key immidietaly (while i am in air) i get lifted and the code starts to work. The problem is why cant i get lifted from ground and why does it only works while i m in air ?
__________________

My Plugins For ZP

Inactive due to College and Studies

Last edited by abdul-rehman; 09-03-2011 at 13:55.
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 09-03-2011 , 14:15   Re: pev_velocity not working properly
Reply With Quote #2

First

velocity[2] += 40

=>

velocity[2] += 40.0
__________________
Полный похуизм.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 09-03-2011 , 14:22   Re: pev_velocity not working properly
Reply With Quote #3

I think, it's gravity
You set a constant speed. But you should give an acceleration. For example, add z speed with some interval.
When you in jump, you have intial vertical speed.
__________________
Полный похуизм.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-03-2011 , 14:47   Re: pev_velocity not working properly
Reply With Quote #4

Look at my bullet pogo plugin, it does something similar to what youre trying.
__________________
Bugsy is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 09-03-2011 , 14:58   Re: pev_velocity not working properly
Reply With Quote #5

Quote:
Originally Posted by Flipper_SPb View Post
I think, it's gravity
You set a constant speed. But you should give an acceleration. For example, add z speed with some interval.
When you in jump, you have intial vertical speed.
I kept my use button continuosly pressed, so that 40 units was added continuosly to my velocity
Quote:
Originally Posted by Bugsy View Post
Look at my bullet pogo plugin, it does something similar to what youre trying.
Bugsy, i looked into your plugin and this is how you set the velocity:
Code:
pev( Invoker , pev_velocity , fVelocity ); fVelocity[ 2 ] = get_pcvar_float( g_pStrength ); set_pev( Invoker , pev_velocity , fVelocity );
But wont it set the z velocity to a continous value ? I want the z value to be added to the current one so that if you are falling you will sort of get an upwards push like a real jetpack
Edit: i tried your code and it also haves the same problem, also, your code doesnt accelerates you upwards instead it keeps in a constant z velocity (like i suspected it to do)

I dont get it what is the problem exactly !
__________________

My Plugins For ZP

Inactive due to College and Studies

Last edited by abdul-rehman; 09-03-2011 at 15:02.
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:05.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode