AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   TS Melee (https://forums.alliedmods.net/showthread.php?t=82508)

Spunky 12-24-2008 16:48

TS Melee
 
I'm looking for an alternative method of detecting when a player is hit besides TSFUN, which apparently hasn't worked since 1.70... I'd prefer that it worked basically the same way, if that's at all possible.

CodeMaster 12-24-2008 17:58

Re: TS Melee
 
If you wanna know is player hit in any mean you can use hamsandwich's "Ham_TakeDamage"

Example:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Damage Detect"
#define VERSION "1.0"
#define AUTHOR "CodeMaster"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_TakeDamage,"player","hook_damage",0// if you want post check change 0 to 1
}

public 
hook_damage(id,inflictor_id,attacker_id,Float:damage,damagebits) {
    
// Your code here...
    
    // inflictor_id represents "weapon" id, so maybe if melee attacks has id like custom weapon,
    // you could use:
    
    
if(inflictor_id 30) {     //Higher than highest standard weapon id?
        // if it was kung fu?
    
}
    
    return 
HAM_HANDLED


I'm HIGHLY unsure about that inflictor part, cause I never used melee attacks, but Ham_TakeDamage detects any sort of damage so it still may come handy.

Cheers ;)

Nidza

Spunky 12-24-2008 20:05

Re: TS Melee
 
Thanks, I should be able to make that work.

Spunky 12-26-2008 18:15

Re: TS Melee
 
I can't get that to work.

PHP Code:

public hook_damage(idinflictor_idattacker_idFloat:damagedamagebits)
{
    
// Katana and up, according to tsconst.inc
    
if (inflictor_id >= 34)
        
nrp_setuserstamina(idnrp_getuserstamina(id) - (floatround(damagefloatround_round) / 10))
    else
    {
        
// Ignore worldspawn
        
if (inflictor_id == 0)
        {
        }
        else
            
client_print(idprint_chat"[NRP] Weapons are not allowed!")

        
set_user_health(idget_user_health(id) + floatround(damagefloatround_round))
    }

    return 
HAM_HANDLED




All times are GMT -4. The time now is 09:18.

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