AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   How to push player? (https://forums.alliedmods.net/showthread.php?t=152460)

gCode 03-09-2011 15:01

How to push player?
 
How to push player?

Samantha 03-09-2011 15:12

Re: How to push player?
 
PHP Code:

decl Float:Push[3];
//Put the velocity in that ^.
TeleportEntityClientNULL_VECTORNULL_VECTORPush); 


zeroibis 03-09-2011 15:34

Re: How to push player?
 
Would that not just teleport them to the new location, or does it actually move them there at an adjustable rate?

I always just used SetEntDataVector( client, m_vecBaseVelocity, velocity, true );

gCode 03-09-2011 15:50

Re: How to push player?
 
Samantha, I'm using it... i want to create knockback on event hurt. but it freeze player in sky when he jump or he fall from sky.

Samantha 03-09-2011 15:54

Re: How to push player?
 
You would have to calculate the forces you wanna act on the client, X Y Z. What did u put in the push vectors?

zeroibis, that does work and it wouldn't teleport the client anywhere since we are passing NULL for vectors.

FlaminSarge 03-09-2011 22:44

Re: How to push player?
 
It goes
TeleportEntity(entity, positionvector, anglevector, velocityvector)

So passing null for the first two doesn't change client position, nor angle, just velocity.

Just a clarification for anybody that didn't understand.

Samantha 03-09-2011 23:07

Re: How to push player?
 
Quote:

Originally Posted by FlaminSarge (Post 1430627)
It goes
Just a clarification for anybody that didn't understand.

Thank you for your fabulous clarification FlaminSarge :D

Invader Amoto 03-12-2011 16:00

Re: How to push player?
 
If you want to get a "realistic" feeling push like the explosions in the game give, you should get the client's current velocity, then add the "push" velocity vector to it, and teleport him there. With the way that is suggested, it will feel more like being airblasted or hit with the fan, which basically stops all your momentum and just pushes you at the same speed regardless of what you're doing.

This should go in OnPluginStart() with playerVelOffset as a global variable.
PHP Code:

playerVelOffset FindSendPropOffs("CBasePlayer""m_vecVelocity[0]"); 

And then use this to get "client"'s current velocity
PHP Code:

new Float:currentVelocity[3];
GetEntDataVector(clientplayerVelOffsetcurrentVelocity); 

You can then add a vector to his current velocity, and do what was suggested earlier in the thread with TeleportEntity.


All times are GMT -4. The time now is 20:26.

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