Raised This Month: $ Target: $400
 0% 

Pushing someone away


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-13-2009 , 12:40   Re: Pushing someone away
Reply With Quote #2

Code:
// minimum radius for player to be pushed away #define PUSH_RADIUS 200.0 // maximum speed for player to be pushed away // (maximum speed will be used if player is closest to the origin, otherwise it is proportional to the player's distance) #define PUSH_SPEED 500.0 PushPlayer(client, const Float:center[3]) {     new Float:origin[3];     pev(client, pev_origin, origin);         new Float:dist = get_distance_f(origin, center);     if( dist > PUSH_RADIUS ) return;         new Float:speed = (1.0 - (dist / PUSH_RADIUS)) * PUSH_SPEED;         new Float:velocity[3];     velocity[0] = origin[0] - center[0];     velocity[1] = origin[1] - center[1];     velocity[2] = origin[2] - center[2];         new Float:length = vector_length(velocity);         velocity[0] = velocity[0] / length * speed;     velocity[1] = velocity[1] / length * speed;     velocity[2] = velocity[2] / length * speed;         new Float:current[3];     pev(client, pev_velocity, current);         current[0] += velocity[0];     current[1] += velocity[1];     current[2] += velocity[2];         set_pev(client, pev_velocity, current); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
 



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 16:58.


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