AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Pass player if attacked? (https://forums.alliedmods.net/showthread.php?t=102366)

MasterKy 09-01-2009 13:27

Pass player if attacked?
 
PHP Code:

public plugin_init()
{
    
register_plugin(PLUGVERSAUTH);
    
register_event("DeathMsg""EVENT_TakeDamage""be")
    
RegisterHam(Ham_TakeDamage"player""EVENT_TakeDamage")
}

public 
EVENT_TakeDamage(id){
new 
iPlayers32 ];
new 
iPlayerCount
get_players
iPlayersiPlayerCount"ae""TERRORIST" ); 
        if(
iPlayerCount == 1){
        
        }else
        if(
iPlayerCount == 2){
        new 
CsTeams:userTeam cs_get_user_team(id)
        if(
get_user_attacker(id)){
            if(
userTeam == CS_TEAM_T) {
            
cs_set_user_team(id,CS_TEAM_CT)
            
captured(id)
                }
            }
        }else{
        new 
CsTeams:userTeam cs_get_user_team(id)
        if(
get_user_attacker(id)){
            if(
userTeam == CS_TEAM_T) {
            
cs_set_user_team(id,CS_TEAM_CT)
            
captured(id)
            
client_print(0,print_chat"Hahaha.A terrorist has been captured!!!",id)
            
server_cmd("amx_execall spk misc/risamalo")
                }
            }
        }
        return 
PLUGIN_CONTINUE


Hello!
this is my plugin but i have a problem :|
it send the TR player for CT if him be attacked.
I need it to send the terrorist
for CT if a CT shoot him, but do not want him to lose HP and do not want him(Terrorist) to go (to CT team) if a terrorist attack him.

Thanks for all!

Mxnn 09-01-2009 13:39

Re: Pass player if attacked?
 
In the first if, in the true part you must to put anything.
An if can't be without a true part and with a false part.
Remake the condition..

fysiks 09-01-2009 17:38

Re: Pass player if attacked?
 
Try this (untested):

PHP Code:

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

public plugin_init()
{
    
register_plugin("Plugin Name""1.0""Author");
    
// register_event("DeathMsg", "EVENT_TakeDamage", "be")
    
RegisterHam(Ham_TakeDamage"player""EVENT_TakeDamage")
}

public 
EVENT_TakeDamage(idvictimidinflictoridattackerFloat:damagedamagebits)
{
    if( 
idvictim 33 && idattacker 33 )
    {
        new 
iPlayerCount get_playersnum()
        new 
CsTeams:TeamVictim cs_get_user_team(idvictim)
        new 
CsTeams:TeamAttacker cs_get_user_team(idattacker)
        
        if( 
iPlayerCount && TeamVictim != TeamAttacker )
        {
            switch( 
_:TeamVictim )
            {
                case 
CS_TEAM_CT:
                {
                    
cs_set_user_team(idvictimCS_TEAM_T)
                    
client_print(0print_chat"Hahaha. A Counter-Terrorist has been captured by the Terrorists.")
                }
                case 
CS_TEAM_T:
                {
                    
cs_set_user_team(idvictimCS_TEAM_CT)
                    
client_print(0print_chat"Hahaha. A Terrorist has been captured by the Counter-Terrorists.")
                }
            }
        }
    }

    return 
HAM_SUPERCEDE



zacky 09-01-2009 17:46

Re: Pass player if attacked?
 
Quote:

Originally Posted by fysiks (Post 920360)
Try this (untested):

PHP Code:

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

public plugin_init()
{
    
register_plugin("Plugin Name""1.0""Author");
    
// register_event("DeathMsg", "EVENT_TakeDamage", "be")
    
RegisterHam(Ham_TakeDamage"player""EVENT_TakeDamage")
}

public 
EVENT_TakeDamage(idvictimidinflictoridattackerFloat:damagedamagebits)
{
    if( 
idvictim 33 && idattacker 33 )
    {
        new 
iPlayerCount get_playersnum()
        new 
CsTeams:TeamVictim cs_get_user_team(idvictim)
        new 
CsTeams:TeamAttacker cs_get_user_team(idattacker)
        
        if( 
iPlayerCount && TeamVictim != TeamAttacker )
        {
            switch( 
_:TeamVictim )
            {
                case 
CS_TEAM_CT:
                {
                    
cs_set_user_team(idvictimCS_TEAM_T)
                    
client_print(0print_chat"Hahaha. A Counter-Terrorist has been captured by the Terrorists.")
                }
                case 
CS_TEAM_T:
                {
                    
cs_set_user_team(idvictimCS_TEAM_CT)
                    
client_print(0print_chat"Hahaha. A Terrorist has been captured by the Counter-Terrorists.")
                }
            }
        }
    }

    return 
HAM_SUPERCEDE



You forgot captured(id) from his code.

fysiks 09-01-2009 17:54

Re: Pass player if attacked?
 
Quote:

Originally Posted by zacky (Post 920363)
You forgot captured(id) from his code.

It was intentional. I don't know what it does. All I need to know is if my code is what he needed. Then after that he can add that as he pleases. Everything that he expained in his post is in my code.


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

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