Raised This Month: $32 Target: $400
 8% 

Information about Fall Death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mixtaz
Junior Member
Join Date: Sep 2017
Old 08-24-2018 , 11:56   Information about Fall Death
Reply With Quote #1

Hello everyone, I was on my way making plugin which approach was to inform players about someone's death caused by fall damage. I've already found correct event to hook it up and the information shows just fine. However the problem appears when I want to include the distance of the lethal fall. I've made inital code however regardless of the height I'm droping off it shows just "(1)". Without further ado, let me present my code.

PHP Code:
#include <amxmodx>
#include <colorchat>
#include <vector>
#include <fakemeta>

#define PLUGIN  "Fall Info"
#define VERSION "1.6"
#define AUTHOR  "Mixtaz"

new origin1[3];
new 
origin2[3]; 
new 
Float:modMeter 32.00

new const Prefix[] = "GM"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event"DeathMsg""eDeathMsg""a" );
    
register_forward(FM_CmdStart"CmdStartPre");
}
public 
CmdStartPre(iduc_handle){
    new 
flags pev(idpev_flags);
    if((
get_uc(uc_handleUC_Buttons) & IN_JUMP) && !(flags FL_ONGROUND) && !(pev(idpev_oldbuttons) & IN_JUMP)) {
    
get_user_originidorigin1 );
    }
    if(
flags FL_ONGROUND){ 
    
get_user_originidorigin2 );
    }
}


public 
eDeathMsg()
{
    new 
iKiller read_data(1);
    new 
iVictim read_data(2);
    new 
vName[33];
    
get_user_name(iVictimvNamesizeof vName 1);
    new 
Dystans get_distance(origin1origin2);

    static 
sWeapon[16]; 
    
read_data4sWeaponsizeofsWeapon ) - );
        
    if( !
iKiller && equalsWeapon"world") ) 
    switch(
random(4)){
    case 
0ColorChat(0GREEN"[%s]^x03 %s^x01 nie zaliczyl bezpiecznego ladowania (%d)."PrefixvNamefloatround(Dystans modMeter));
    case 
1ColorChat(0GREEN"[%s]^x03 %s^x01 nie mial dodatkowego spadochronu (%d)."PrefixvNamefloatround(Dystans modMeter));
    case 
2ColorChat(0GREEN"[%s]^x03 %s^x01 zakonczyl zywot poprzez skok (%d)."PrefixvNamefloatround(Dystans modMeter));
    case 
3ColorChat(0GREEN"[%s]^x03 %s^x01 spadl z wysokosci (%d)."PrefixvNamefloatround(Dystans modMeter));
    }


Mixtaz is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-24-2018 , 12:48   Re: Information about Fall Death
Reply With Quote #2

You are retrieving origin2 too soon, he did not land yet, didn't even jump.
__________________
HamletEagle is offline
Mixtaz
Junior Member
Join Date: Sep 2017
Old 08-24-2018 , 13:17   Re: Information about Fall Death
Reply With Quote #3

Could you by any chance give me a hint, when would be the proper moment to do so?

It seems as if the first origin has been retrieved correctly since player is midair, how then can I innitiate the second one?
Mixtaz is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 08-24-2018 , 14:26   Re: Information about Fall Death
Reply With Quote #4

Try Ham_Killed in PRE.
__________________
My English is A0
E1_531G is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-24-2018 , 14:29   Re: Information about Fall Death
Reply With Quote #5

You can traceline from player's origin to ground, then retrieve TR_vecEndPos. Then use get_distance_f between start origin and end origin or try what E1_531G said.
__________________

Last edited by HamletEagle; 08-24-2018 at 14:30.
HamletEagle is offline
Reply


Thread Tools
Display Modes

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 19:09.


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