AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   dmg molotov (https://forums.alliedmods.net/showthread.php?t=314294)

szogun 02-12-2019 11:22

dmg molotov
 
I have a little problem with the plugin that asks dmg after entering molotova from his team

PHP Code:

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#define PLUGIN_AUTHOR "f0re4ch"
#define PLUGIN_VERSION "1.0"

public Plugin:myinfo =
{
    
name "Competitive Anti-FF",
    
author PLUGIN_AUTHOR,
    
description "Protects Players from Friendly-Fire but enable molotov damage",
    
version PLUGIN_VERSION,
    
url "http://kpservidores.com"
};

public 
OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3]&#65279;)
{
    
int attackerUserId attacker;
    
int victimUserId victim;

    
char WeaponCallBack[32];
    
GetEdictClassname(inflictorWeaponCallBacksizeof(WeaponCallBack));

    if ((!
IsValidEntity(victimUserId)) || (!IsValidEntity(attackerUserId)))
        return 
Plugin_Continue;

    if ((
strlen(WeaponCallBack) <= 0) || (attackerUserId == victimUserId) || (GetClientTeam(victimUserId) != GetClientTeam(attackerUserId)) )
        return 
Plugin_Continue;

    if (
StrEqual(WeaponCallBack"inferno"false))
        return 
Plugin_Continue;

    return 
Plugin_Handled;


Quote:

[SM] Exception reported: Client index 306 is invalid
[SM] Blaming: no_ff_molotov.smx
[SM] Call stack trace:
[SM] [0] GetClientTeam
[SM] [1] Line 21, no_ff_molotov.sp::OnTakeDamage
[SM] Exception reported: Client index 306 is invalid

Ilusion9 02-12-2019 11:53

Re: dmg molotov
 
PHP Code:


#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 

public OnClientPutInServer(int client

    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage); 


public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3]) 
{
    if (
attacker == victim)
    {
        return 
Plugin_Continue// do self damage
    
}
    
    if (
inflictor != -1// if there are no inflictors, this should be -1, you can remove it if the damage in molotov doesnt work
    
{
        
char weaponName[32]; 
        
GetEdictClassname(inflictorweaponNamesizeof(weaponName)); 
        
        if (
StrEqual(weaponName"inferno"false))
        {
            return 
Plugin_Continue// do damage in molotov
        
}
    }
    
    if (
IsValidClient(victim))
    {
        if (
IsValidClient(attacker))
        {
            if (
GetClientTeam(attacker) == GetClientTeam(victim))
            {
                return 
Plugin_Handled// stop friendly fire, except molotovs
            
}
        }
    }
    
    return 
Plugin_Continue
}

bool IsValidClient(int client)
{
    if (
client || client MaxClients)
    {
        return 
false;
    }
    
    return 
IsClientInGame(client);



Ejziponken 11-14-2019 15:38

Re: dmg molotov
 
Quote:

Originally Posted by Ilusion9 (Post 2639336)
PHP Code:


#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 

public OnClientPutInServer(int client

    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage); 


public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3]) 
{
    if (
attacker == victim)
    {
        return 
Plugin_Continue// do self damage
    
}
    
    if (
inflictor != -1// if there are no inflictors, this should be -1, you can remove it if the damage in molotov doesnt work
    
{
        
char weaponName[32]; 
        
GetEdictClassname(inflictorweaponNamesizeof(weaponName)); 
        
        if (
StrEqual(weaponName"inferno"false))
        {
            return 
Plugin_Continue// do damage in molotov
        
}
    }
    
    if (
IsValidClient(victim))
    {
        if (
IsValidClient(attacker))
        {
            if (
GetClientTeam(attacker) == GetClientTeam(victim))
            {
                return 
Plugin_Handled// stop friendly fire, except molotovs
            
}
        }
    }
    
    return 
Plugin_Continue
}

bool IsValidClient(int client)
{
    if (
client || client MaxClients)
    {
        return 
false;
    }
    
    return 
IsClientInGame(client);



Cant make this work. If I sett FF on, then team can kill eachother and if I set it off, then molotovs dont do damage.

paulo_crash 02-06-2020 09:17

Re: dmg molotov
 
Quote:

Originally Posted by Ilusion9 (Post 2639336)
PHP Code:


#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 

public OnClientPutInServer(int client

    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage); 


public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3]) 
{
    if (
attacker == victim)
    {
        return 
Plugin_Continue// do self damage
    
}
    
    if (
inflictor != -1// if there are no inflictors, this should be -1, you can remove it if the damage in molotov doesnt work
    
{
        
char weaponName[32]; 
        
GetEdictClassname(inflictorweaponNamesizeof(weaponName)); 
        
        if (
StrEqual(weaponName"inferno"false))
        {
            return 
Plugin_Continue// do damage in molotov
        
}
    }
    
    if (
IsValidClient(victim))
    {
        if (
IsValidClient(attacker))
        {
            if (
GetClientTeam(attacker) == GetClientTeam(victim))
            {
                return 
Plugin_Handled// stop friendly fire, except molotovs
            
}
        }
    }
    
    return 
Plugin_Continue
}

bool IsValidClient(int client)
{
    if (
client || client MaxClients)
    {
        return 
false;
    }
    
    return 
IsClientInGame(client);



I will be doing the test with this version, but from what I could see it is only with molotovs.

Someone would have one that does damage with all the grenades in the game, except the shot.

I tried this, but same problem, except that apparently I realized that the explosion of the C4 is not keeping players... :)

https://forums.alliedmods.net/showthread.php?t=301081


All times are GMT -4. The time now is 14:39.

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