Raised This Month: $ Target: $400
 0% 

Calculating fall distance


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-04-2009 , 15:00   Re: Calculating fall distance
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #include <hamsandwich> new bool:g_alive[33]; new bool:g_was_on_ground[33]; new bool:g_falling[33]; public plugin_init() {     RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn", 1);     RegisterHam(Ham_Killed, "player", "FwdPlayerDeath", 1);     RegisterHam(Ham_Player_PreThink, "player", "FwdPlayerPreThink"); } public client_disconnect(client) {     g_alive[client] = false; } public FwdPlayerSpawn(client) {     if( is_user_alive(client) )     {         g_alive[client] = true;         g_falling[client] = false;     } } public FwdPlayerDeath(client) {     g_alive[client] = false; } public FwdPlayerPreThink(client) {     if( !g_alive[client] ) return;         if( g_falling[client] && pev(client, pev_movetype) != MOVETYPE_WALK )     {         g_falling[client] = false;     }         static Float:fall_origin[33][3];         new bool:on_ground = bool:(pev(client, pev_flags) & FL_ONGROUND);         if( on_ground && !g_was_on_ground[client] && g_falling[client] )     {         static Float:origin[3];         pev(client, pev_origin, origin);                 new Float:distance = fall_origin[client][2] - origin[2];         if( distance > 0.0 )         {             client_print(client, print_chat, "You fell %f units!", distance);         }     }     else if( !on_ground && g_was_on_ground[client] )     {         g_falling[client] = true;         pev(client, pev_origin, fall_origin[client]);     }         g_was_on_ground[client] = on_ground; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 02-05-2009 at 12:36.
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 01:53.


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