AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player touch player (https://forums.alliedmods.net/showthread.php?t=336366)

Arje 02-14-2022 09:15

Player touch player
 
Hi, I have a problem and I don't know why this doesn't work. before I could make it work with the same code but now it doesn't, and I didn't change anything.

is there something wrong with the code?

PHP Code:


// this is just to be activated during the dash
new bool:touchAceKatanaPower[SH_MAXSLOTS+1]

//----------------------------------------------------------------------------------------------
public sh_client_death(victimattacker)
{
    if ( 
victim == attacker ) return
    
    new 
randnum random_num(0100)
    new 
katanachance floatround(get_pcvar_float(pcvarPercent) * 100)
    
    new 
clipammowpnid get_user_weapon(attackerclipammo
    
    if ( 
wpnid == CSW_KNIFE && katanachance >= randnum && is_user_alive(attacker) ) {
        
        
dash(attacker)
        
        new 
ptr attacker
        
new ptd victim 
        pfn_touch
(ptrptd)   
        
    }
}
//----------------------------------------------------------------------------------------------
//        EVENT of DASH + DAMAGE
//----------------------------------------------------------------------------------------------
public dash(attacker)
{
    if (!(
pev(attackerpev_flags) & FL_ONGROUND)) return
    
    static 
Float:velocity[3]
    
velocity_by_aim(attacker1750velocity)
        
    
velocity[2] = 100.0        // z
    
set_pev(attackerpev_velocityvelocity)
    
    
touchAceKatanaPower[attacker] = true
}
//-----------------------------------------
public pfn_touch(ptrptd
{
    if(!
is_valid_ent(ptr) || !is_valid_ent(ptd)) return PLUGIN_CONTINUE
            
    
if(!is_user_alive(ptr) || !is_user_alive(ptd)) return PLUGIN_CONTINUE
        
    
new classname[32]
    
entity_get_string(ptrEV_SZ_classnameclassname31)
    if ( 
equal(classname"player") ) {
        
        if ( 
touchAceKatanaPower[ptr] && get_user_team(ptr) != get_user_team(ptd) ) {
        
            
// This code is for kill
            
new damage read_data(2)
            
sh_extra_damage(ptdptrdamage"Por Katana"0SH_DMG_KILL)
        }    
    }
    
    
     return 
PLUGIN_HANDLED



HamletEagle 02-14-2022 09:45

Re: Player touch player
 
What is the problem? What could you do before and does not work now?

Arje 02-14-2022 09:55

Re: Player touch player
 
I solved it, it was because I have many plugins with "public pfn_touch", and in some it had "plugin_handled" and this stopped everyone's fpn touch, so..

My question is, should I remove "public" from "public fpn_touch" in each of the scripts?
I don't know exactly how that works

OciXCrom 02-14-2022 15:20

Re: Player touch player
 
If you remove "public", the function won't work and the plugin will throw an error.

What you need to remove is PLUGIN_HANDLED. This blocks the touch event from triggering, so unless you want to do that, don't use PLUGIN_HANDLED, or put other plugins you want to use before that one in plugins.ini so they don't get blocked.


All times are GMT -4. The time now is 11:31.

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