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

old origin (fall damage)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-30-2018 , 16:40   old origin (fall damage)
Reply With Quote #1

Hello, I'm trying to save player's origin before of he fell and "teleport" him to this origin if he receive fall damage. Since is there no specific way to do this, what I did then was loop through players each 0.1 seconds, save their origin and teleport they when receive fall damage.

It's working but sometimes the saved origin is the same point from where they fall, so when I teleport them, they stay falling infinitly. Also, I tried to save origin while they climb ladder, but if I teleport them to this origin, same problem happen.

Spoiler
__________________









Last edited by CrazY.; 12-30-2018 at 16:45.
CrazY. is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 12-31-2018 , 06:00   Re: old origin (fall damage)
Reply With Quote #2

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "raizo"

new his_position[33][3]
new last_position[33][3]

new maxplayers

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    RegisterHam(Ham_TakeDamage, "player", "Player_TakeDamage", false);

    maxplayers = get_maxplayers();

    set_task(1.0,"update",0,"",0,"b",0)

}

public update()
{
    for(new id;id < maxplayers;id++)
    {
        if(is_user_alive(id))
	{
            check(id)
        }
    }
}

public Player_TakeDamage(id, iInflictor, iAttacker, Float: fDamage, bitsDamageType) 
{
    if(!is_user_connected(id)) 
    { 
        return HAM_IGNORED;
    }
    
    if(bitsDamageType & DMG_FALL && fDamage >= pev(id, pev_health)) 
    {
        move_to_check(id)
        return HAM_SUPERCEDE;
    }
    
    return HAM_IGNORED;
}

stock move_to_check(id) 
{
	set_pev(id, pev_origin, his_position[id])
}

public check(id)
{
    if(is_user_alive(id))
    {
        if(!(pev(id, pev_flags) & FL_ONGROUND))
	{
	    return PLUGIN_HANDLED;
	}
	last_position[id][0] = his_position[id][0]
        last_position[id][1] = his_position[id][1]
	last_position[id][2] = his_position[id][2]
	pev(id, pev_origin, his_position[id])
	his_position[id][2] += 5
	return PLUGIN_HANDLED;
    }
    return PLUGIN_HANDLED;
}
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
E1_531G
Senior Member
Join Date: Dec 2017
Old 12-31-2018 , 10:45   Re: old origin (fall damage)
Reply With Quote #3

Save only the last position when the player is on the ground.
__________________
My English is A0
E1_531G is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 12-31-2018 , 11:26   Re: old origin (fall damage)
Reply With Quote #4

Quote:
Originally Posted by CrazY. View Post
I'm trying to save player's origin before of he fell and "teleport" him to this origin if he receive fall damage.
Is not that what you wanted? be more explicit
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-31-2018 , 11:30   Re: old origin (fall damage)
Reply With Quote #5

Quote:
Originally Posted by E1_531G View Post
Save only the last position when the player is on the ground.
That's what I did.

Code:
if (!(pev(pPlayer, pev_flags) & FL_ONGROUND))         continue;


Quote:
Originally Posted by raizo11 View Post
Spoiler
It's the exact same way as I did.
__________________








CrazY. is offline
shauli
Member
Join Date: Jun 2018
Old 12-31-2018 , 11:39   Re: old origin (fall damage)
Reply With Quote #6

You mean that the origin is in the air or it's on the ground but he's falling because he has some velocity?
If it's velocity, just reset it.

Also, there's something similar on this plugin, you might want to take a look:
https://forums.alliedmods.net/showthread.php?p=806220
shauli is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 12-31-2018 , 15:56   Re: old origin (fall damage)
Reply With Quote #7

Do a check with traceline if the position is "safe" before saving it.
__________________
Black Rose is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-31-2018 , 17:17   Re: old origin (fall damage)
Reply With Quote #8

O_o

Are you sure you read the code that I provided? Because all these suggestions are there...

Quote:
Originally Posted by CrazY. View Post
Code:
public plugin_init() {     set_task(0.1, "HandleFallDamageTask", TASK_FALLDAMAGE, .flags = "b");     RegisterHam(Ham_TakeDamage, "player", "CBasePlayer_TakeDamage"); } public HandleFallDamageTask(iTaskId) {     new Players[MAX_PLAYERS], iPlayerCount;     get_players(Players, iPlayerCount, "ach");     new Float:vecOrigin[3], Float:vecEnd[3], Float:flFallVelocity, Float:flFraction, i, pPlayer, hTr;     hTr = create_tr2();     for (i = 0; i < iPlayerCount; i++)     {         pPlayer = Players[i];         pev(pPlayer, pev_flFallVelocity, flFallVelocity);         if (flFallVelocity > 0.0)             continue;         if (!(pev(pPlayer, pev_flags) & FL_ONGROUND))             continue;         pev(pPlayer, pev_origin, vecOrigin);         xs_vec_copy(vecOrigin, vecEnd);         if (pev(pPlayer, pev_flags) & FL_DUCKING)             vecEnd[2] -= 36.0;         else             vecEnd[2] -= 74.0;         engfunc(EngFunc_TraceLine, vecOrigin, vecEnd, IGNORE_MONSTERS, pPlayer, hTr);         get_tr2(hTr, TR_flFraction, flFraction);         if (flFraction >= 0.9)             continue;         xs_vec_copy(vecOrigin, g_vecOrigin[pPlayer]);     }     free_tr2(hTr); } public CBasePlayer_TakeDamage(this, pInflictor, pAttacker, Float:flDamage, bitsDamageType) {     if (!(bitsDamageType & DMG_FALL))         return HAM_IGNORED;     set_pev(this, pev_velocity, Float:{0.0, 0.0, 0.0});     set_pev(this, pev_punchangle, Float:{0.0,0.0,0.0});     engfunc(EngFunc_SetOrigin, this, g_vecOrigin[this]);     SetHamReturnInteger(false);     return HAM_SUPERCEDE; }
__________________








CrazY. is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 12-31-2018 , 18:52   Re: old origin (fall damage)
Reply With Quote #9

Quote:
Originally Posted by CrazY. View Post
O_o

Are you sure you read the code that I provided? Because all these suggestions are there...
I actually didn't, sorry.
__________________
Black Rose is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-31-2018 , 19:21   Re: old origin (fall damage)
Reply With Quote #10

I really cant think about anything else than using player prethink forward in this.

PHP Code:
#define PLAYER_FATAL_FALL_SPEED 980.0
#define PLAYER_MAX_SAFE_FALL_SPEED 500.0 // ithink this should be 350.0 not sure
#define PLAYER_FALL_PUNCH_THRESHHOLD 250.0

static Float:fSafeOrigin[33][3];

public 
client_prethink(id)
{
       if(!
is_user_alive(id)) return;

       if((
pev(idpev_flags) & FL_ONGROUND))
       {
            
pev(idpev_originfSafeOrigin[id]);
       }
       else {
            static 
Float:fVelocity[3]
            
pev(idpev_velocityfVelocity)

            if( 
fVelocity[2] <  -PLAYER_MAX_SAFE_FALL_SPEED  ) {
                  
set_pev(idpev_originfSafeOrigin[id])
                  
set_pev(idpev_velocityFloat:{0.0,0.0,0.0});
            }
        }

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-02-2019 at 04:24.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 12:43.


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