AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why this function dont work? (https://forums.alliedmods.net/showthread.php?t=173452)

TheArmagedon 12-05-2011 11:17

Why this function dont work?
 
Im trying to do a simple function, if FF is on then CTs cant kill other CTs...

but it dont work..
look at my code.. whats is wrong? or what i need to do?
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

new bool:ffon;

public 
plugin_init() {
    
register_clcmd("say /friendlyfire""Blablabla")
    
RegisterHam(Ham_TakeDamage"player""dmgevent"
}
public 
dmgevent(victiminflictorattackerFloat:damagebits
{
    
    if(
ffon && cs_get_user_team(attacker) == CS_TEAM_CT && cs_get_user_team(victim) == CS_TEAM_CT) {
        
// return HAM_SUPERCEDE
        // dont work
        // SetHamParamFloat(4, damage = 0.0)
        // dont work
    
}
    
// or
    
new CsTeams:iTeamACsTeams:iTeamV
    iTeamA 
cs_get_user_team(attacker)
    
iTeamV cs_get_user_team(victim)
    
    if(
ffon && iTeamA == CS_TEAM_CT && iTeamV == CS_TEAM_CT)
    {
        
// return HAM_SUPERCEDE
        // dont work
        // SetHamParamFloat(4, damage = 0.0)
        // dont work.....
    
}
    
// the two ways dont work!
}
public 
Blablabla(id)
{
    
ffon = !ffon
    
    
if(ffon) {
        
set_cvar_num("mp_friendlyfire"1)
        
client_print(0print_chat"FF ON");
    } else {
        
set_cvar_num("mp_friendlyfire"0)
        
client_print(0print_chat"FF OFF");
    }



fysiks 12-05-2011 17:32

Re: Why this function dont work?
 
Quote:

Originally Posted by TheArmagedon (Post 1608171)
if FF is on then CTs cant kill other CTs...

That's how FF works already. You just need to change the value of mp_friendlyfire. The server will do the rest of the work for you.

TheArmagedon 12-05-2011 20:58

Re: Why this function dont work?
 
I forgot to explain a thing...
If FF is on, CTs cant kill CTs and Ts can kill Ts.

If i'm a terrorist and a person says "/friendlyfire" friendlyfire will activate/desactivate., then i can kill my friends, otherwise, Im a ct and friendlyfire is ON...then i cant kill the other cts..

I dont know, but.. do you mean the mp_friendlyfire cvar have more options than 1 or 0?
anything like that..? for example:
mp_friendlyfire 2 - set friendly fire only for terrorists
mp_friendlyfire 3 - set friendly fire only for cts

jim_yang 12-05-2011 21:08

Re: Why this function dont work?
 
in your case, you don't have to check mp_friendlyfire is on or off, just make cts can't take damage of cts.

fysiks 12-05-2011 21:59

Re: Why this function dont work?
 
If mp_friendlyfire is 0 then nobody can kill their teammates. You have to leave friendlyfire on then handle the damage.

Snaker beatter 12-06-2011 06:31

Re: Why this function dont work?
 
Try this anyway :) UNTESTED
PHP Code:

#include <amxmodx> 
#include <cstrike> 
#include <hamsandwich> 

new bool:ffon

public 
plugin_init() { 
    
register_clcmd("say /friendlyfire""Blablabla"
    
RegisterHam(Ham_TakeDamage"player""dmgevent")  

public 
dmgevent(victiminflictorattackerFloat:damagebits)  

     
    if(
ffon && cs_get_user_team(attacker) == CS_TEAM_CT && cs_get_user_team(victim) == CS_TEAM_CT) { 
        
SetHamParamFloat(4damage 0.0
        return 
HAM_SUPERCEDE 
    

    
// or 
    
new CsTeams:iTeamACsTeams:iTeamV 
    iTeamA 
cs_get_user_team(attacker
    
iTeamV cs_get_user_team(victim
     
    if(
ffon && iTeamA == CS_TEAM_CT && iTeamV == CS_TEAM_CT
    { 
        
SetHamParamFloat(4damage 0.0
        return 
HAM_SUPERCEDE 
    

    
// the two ways dont work! 

public 
Blablabla(id

    
ffon = !ffon 
     
    
if(ffon) { 
        
set_cvar_num("mp_friendlyfire"1
        
client_print(0print_chat"FF ON"); 
    } else { 
        
set_cvar_num("mp_friendlyfire"0
        
client_print(0print_chat"FF OFF"); 
    } 



jim_yang 12-06-2011 07:35

Re: Why this function dont work?
 
what's the point of SetHamParamX before return HAM_SUPERCEDE

TheArmagedon 12-06-2011 08:00

Re: Why this function dont work?
 
Quote:

Originally Posted by jim_yang (Post 1608413)
in your case, you don't have to check mp_friendlyfire is on or off, just make cts can't take damage of cts.

I already tried that... dont work ):
Quote:

Originally Posted by fysiks (Post 1608429)
If mp_friendlyfire is 0 then nobody can kill their teammates. You have to leave friendlyfire on then handle the damage.

"If mp_friendlyfire is 0 then nobody can kill their teammates." Yes, i know that but you say after this, "you have to leave friendlyfire on then handle the damage", Thats what i'm trying to do but, i dont know why... it dont work


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

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