AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A way to make No fall damage (https://forums.alliedmods.net/showthread.php?t=113903)

benamo6 12-31-2009 07:08

A way to make No fall damage
 
I searched some codes, but I cant get it.
I need a way to add fall damage to a menu (shop).

ConnorMcLeod 12-31-2009 07:21

Re: A way to make No fall damage
 
create a global variable that handles if players are immuned or not about fall damage, change that variable when a player buy no fall damage, or die or whatever.

PHP Code:

const MAX_PLAYERS 32

new g_bNoFallDamage[MAX_PLAYERS+1]

public 
plugin_init()
{
    
RegisterHam(Ham_TakeDamage"player""Ham_CBasePlayer_TakeDamage_Pre")
}

public 
Ham_CBasePlayer_TakeDamage_Pre( const id, const iInflictor, const iAttacker, const Float:flDamage, const iDamageType )
{
    if( 
iDamageType == DMG_FALL && g_bNoFallDamage[id] )
    {
    
//    SetHamParamFloat(4, 0.0)
        
SetHamReturnInteger(0)
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED



benamo6 12-31-2009 07:23

Re: A way to make No fall damage
 
Why is this line commented?
PHP Code:

//    SetHamParamFloat(4, 0.0) 


ConnorMcLeod 12-31-2009 07:25

Re: A way to make No fall damage
 
Because i don't think it is needed, you could use it and don't set the return interger though.

Arkshine 12-31-2009 07:26

Re: A way to make No fall damage
 
In case returning 0 won't work I guess, you can change on the fly the damage param since if damage is 0 the function will be aborted. But returning 0 should work.

benamo6 12-31-2009 07:29

Re: A way to make No fall damage
 
Thanks, but im new at scripting, I added all those things to my code, but I dont know how to make this
Quote:

create a global variable that handles if players are immuned or not about fall damage, change that variable when a player buy no fall damage, or die or whatever.
Can you give me an example please?

ConnorMcLeod 12-31-2009 07:30

Re: A way to make No fall damage
 
It is already done, g_bNoFallDamage is the variable.
When a player buy no falldamage, set g_bNoFallDamage[id] = true
Set it to false in client_putinserver, and if you need in player spawn/dies etc..

benamo6 12-31-2009 07:41

Re: A way to make No fall damage
 
I get an error when I compile.
Undefined symbol "id" on line 510 (this is the line where I have g_bNoFallDamage[id] = true)

Arkshine 12-31-2009 07:44

Re: A way to make No fall damage
 
Replace 'id' by the var you use for the player.

AppStore 12-31-2009 08:17

Re: A way to make No fall damage
 
PHP Code:

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

const MAX_PLAYERS 32

new g_bNoFallDamage[MAX_PLAYERS+1]

public 
plugin_init()
{
    
RegisterHam(Ham_TakeDamage"player""Ham_CBasePlayer_TakeDamage_Pre")
}

public 
Ham_CBasePlayer_TakeDamage_Pre( const id, const iInflictor, const iAttacker, const Float:flDamage, const iDamageType )
{
    if( 
iDamageType == DMG_FALL && g_bNoFallDamage[id] )
    {
    
//    SetHamParamFloat(4, 0.0)
        
SetHamReturnInteger(0)
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED




All times are GMT -4. The time now is 04:12.

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