AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Jailbreak Box can kill each other CT (https://forums.alliedmods.net/showthread.php?t=249975)

Fuck For Fun 10-15-2014 13:28

Jailbreak Box can kill each other CT
 
I have a problem, I run the Box fast Enabled and Disable
So at the same time you can quickly kill the CT, and I just run enable it does not kill ..

Code:

/* Plugin generated by AMXX-Studio */

#include < amxmodx >
#include < cstrike >
#include < fakemeta_util >
#include < hamsandwich >
#include < ColorChat >

#define PLUGIN "Jailbreak Box Menu"
#define VERSION "1.1"
#define AUTHOR "CheezPuff aka Fuck For Fun ;]"

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)

    register_clcmd( "say /box", "cmdBox" );
   
    register_logevent( "CmdRoundStart", 2, "1=Round_Start" );
    RegisterHam( Ham_TakeDamage, "player", "HamTakeDamage" );
}

public CmdRoundStart()
{
    server_cmd( "mp_friendlyfire 0" );
}

public cmdBox( client )
{             
        if ( !is_user_alive( client ) || cs_get_user_team( client ) != CS_TEAM_CT )
        {
                ColorChat( client, GREEN, "[Jailbreak] ^1You must to be^x03 Alive Guards^x01 to do this^x04 command.");
                return 1;
        }
   
    new szMenu[ 50 ], iMenu;
    formatex( szMenu, charsmax( szMenu ), "\r[Jailbreak] \wBox Menu \d/*Built By \yCheezPuff\d");

    iMenu = menu_create( szMenu, "sub_box" );
   
    menu_additem( iMenu, "Box \yActive");
    menu_additem( iMenu, "Box \yDeactive^n");
    menu_additem( iMenu, "Reset Health : \r[ \wTerrorist \r]" );

    menu_display( client, iMenu, 0 );
    return PLUGIN_HANDLED;
}

public sub_box(client, iMenu, item)
{     
    if( item == MENU_EXIT )
        return 1;
     
    switch( item )
    {
        case 0:
        {
            server_cmd( "mp_friendlyfire 1" );
            set_hudmessage(random_num(1,250), random_num(1,255), random_num(1,256), -1.0, -1.0, 0, 6.0, 12.0);
            show_hudmessage(0, "Gurad: %s - Active Box", szName);
            ColorChat( 0, GREEN, "[Jailbreak]^1 Guard:^3 %s ^1- Active ^4Box", szName( client ) );
        }
       
        case 1:
        {
            server_cmd( "mp_friendlyfire 0" );
            set_hudmessage(random_num(1,255), random_num(1,255), random_num(1,255), -1.0, -1.0, 0, 6.0, 12.0);
            show_hudmessage(0, "Gurad: %s - Disactived JailBreak Box",szName);
            ColorChat( 0, GREEN, "[Jailbreak]^1 Guard:^3 %s ^1- Disactived ^4Box", szName( client ) );
        }
       
        case 2:
        {
                          new players[ 32 ], pnum;
                          get_players( players, pnum, "aceh", "TERRORIST" );
                     
                          for(new i = 1; i <= pnum; i++)
                          fm_set_user_health( i, 100 );
 
                          ColorChat( 0, GREEN, "[Jailbreak]^3 %s^1 has reseted HP To ^4Prisoner's^1 Team!", szName( client ));
                       
                          cmdBox( client );
                          return 1;
                }             
        }
 
        return 1;
}

public HamTakeDamage( victim, inflictor, attacker, Float:damage, damagebits )
{
        if ( !is_user_connected( attacker ) || !is_user_alive( attacker ) )
                return HAM_IGNORED;
     
        return ( cs_get_user_team( attacker ) == CS_TEAM_CT && cs_get_user_team( victim ) == cs_get_user_team( attacker ) ?  HAM_SUPERCEDE : HAM_IGNORED);

stock GetUserName( client )
{
    static szName[ 32 ];
   
    get_user_name( client, szName, charsmax( szName ) );
   
    return szName;
}


Natsheh 10-16-2014 15:29

Re: Jailbreak Box can kill each other CT
 
use ( set_pcvar_num ) instead of ( server_cmd )

PHP Code:

new g_cvar_box

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd"say /box""cmdBox" );
    
    
register_logevent"CmdRoundStart"2"1=Round_Start" );
    
RegisterHamHam_TakeDamage"player""HamTakeDamage" );
    
    
g_cvar_box get_cvar_pointer("mp_friendlyfire")
}

public 
CmdRoundStart()
{
    
set_pcvar_num(g_cvar_box0)
}

public 
cmdBoxclient )
{              
    if ( !
is_user_aliveclient ) || cs_get_user_teamclient ) != CS_TEAM_CT )
    {
          
ColorChatclientGREEN"[Jailbreak] ^1You must to be^x03 Alive Guards^x01 to do this^x04 command.");
          return 
PLUGIN_HANDLED
    
}
    
    new 
szMenu50 ], iMenu;
    
formatexszMenucharsmaxszMenu ), "\r[Jailbreak] \wBox Menu \d/*Built By \yCheezPuff\d");

    
iMenu menu_createszMenu"sub_box" );
    
    
menu_additemiMenu"Box \yActive");
    
menu_additemiMenu"Box \yDeactive^n");
    
menu_additemiMenu"Reset Health : \r[ \wTerrorist \r]" );

    
menu_displayclientiMenu);
    return 
PLUGIN_CONTINUE;
}

public 
sub_box(clientiMenuitem)
{      
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(iMenu)
        return 
PLUGIN_HANDLED
    
}
       
    switch( 
item )
    {
        case 
0:
        {
            
set_pcvar_num(g_cvar_box1)
            
set_hudmessage(random_num(1,250), random_num(1,255), random_num(1,256), -1.0, -1.006.012.0);
            
show_hudmessage(0"Gurad: %s - Active Box"GetUserName(client));
            
ColorChat0GREEN"[Jailbreak]^1 Guard:^3 %s ^1- Active ^4Box"GetUserName(client) );
        }
        
        case 
1:
        {
            
set_pcvar_num(g_cvar_box1)
            
set_hudmessage(random_num(1,255), random_num(1,255), random_num(1,255), -1.0, -1.006.012.0);
            
show_hudmessage(0"Gurad: %s - Disactived JailBreak Box"GetUserName(client));
            
ColorChat0GREEN"[Jailbreak]^1 Guard:^3 %s ^1- Disactived ^4Box"GetUserName(client) );
        }
        
        case 
2:
        {
               new 
players32 ], pnum;
               
get_playersplayerspnum"aceh""TERRORIST" );
               
               for(new 
0pnumi++)
                        
fm_set_user_healthplayers[i], 100 );
 
               
ColorChat0GREEN"[Jailbreak]^3 %s^1 has reseted HP To ^4Prisoner's^1 Team!"GetUserName(client));
               
               
cmdBoxclient );
        }              
    }
    return 
PLUGIN_HANDLED
}

public 
HamTakeDamagevictiminflictorattackerFloat:damagedamagebits )
{
        if (!
get_pcvar_num(g_cvar_box))
                       return 
HAM_IGNORED
        
if ( (!is_user_connectedattacker ) || !is_user_aliveattacker ))  && (!is_user_connected(victim) || !is_user_alivevictim )))
                return 
HAM_IGNORED;
       
        static 
CsTeams:AteamCsTeams:Vteam
        Ateam 
cs_get_user_team(attacker)
        
Vteam cs_get_user_team(victim)
        if(
Ateam == CS_TEAM_CT && Vteam == CS_TEAM_CT)
                   return 
HAM_SUPERCEDE
        
return HAM_IGNORED
}

stock GetUserNameclient )
{
    static 
szName32 ];
    
    
get_user_nameclientszNamecharsmaxszName ) );
    
    return 
szName;



HamletEagle 10-16-2014 15:33

Re: Jailbreak Box can kill each other CT
 
DON'T use set_cvar_num, use set_pcvar_num.

Natsheh 10-16-2014 15:47

Re: Jailbreak Box can kill each other CT
 
Quote:

Originally Posted by HamletEagle (Post 2211864)
DON'T use set_cvar_num, use set_pcvar_num.


the cvar is already exist why use set_pcvar_num???

YamiKaitou 10-16-2014 16:03

Re: Jailbreak Box can kill each other CT
 
Quote:

Originally Posted by Natsheh (Post 2211870)
the cvar is already exist why use set_pcvar_num???

You should always be using pCVars. Each call to *et_cvar_* results in a complete search of the CVar list until it finds the CVar it needs. Using *et_pcvar_*, you only search through the list once (if using get_cvar_pointer) or you know exactly where the CVar is (when using register_cvar)

Natsheh 10-16-2014 16:13

Re: Jailbreak Box can kill each other CT
 
Quote:

Originally Posted by YamiKaitou (Post 2211877)
You should always be using pCVars. Each call to *et_cvar_* results in a complete search of the CVar list until it finds the CVar it needs. Using *et_pcvar_*, you only search through the list once (if using get_cvar_pointer) or you know exactly where the CVar is (when using register_cvar)

Thanks for the information!

Fuck For Fun 10-16-2014 17:55

Re: Jailbreak Box can kill each other CT
 
Quote:

Originally Posted by Natsheh (Post 2211863)
use ( set_cvar_num ) instead of ( server_cmd )

PHP Code:

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd"say /box""cmdBox" );
    
    
register_logevent"CmdRoundStart"2"1=Round_Start" );
    
RegisterHamHam_TakeDamage"player""HamTakeDamage" );
}

public 
CmdRoundStart()
{
    
server_cmd"mp_friendlyfire 0" );
}

public 
cmdBoxclient )
{              
         if ( !
is_user_aliveclient ) || cs_get_user_teamclient ) != CS_TEAM_CT )
         {
                
ColorChatclientGREEN"[Jailbreak] ^1You must to be^x03 Alive Guards^x01 to do this^x04 command.");
                return 
PLUGIN_HANDLED
         
}
    
    new 
szMenu50 ], iMenu;
    
formatexszMenucharsmaxszMenu ), "\r[Jailbreak] \wBox Menu \d/*Built By \yCheezPuff\d");

    
iMenu menu_createszMenu"sub_box" );
    
    
menu_additemiMenu"Box \yActive");
    
menu_additemiMenu"Box \yDeactive^n");
    
menu_additemiMenu"Reset Health : \r[ \wTerrorist \r]" );

    
menu_displayclientiMenu);
    return 
PLUGIN_CONTINUE;
}

public 
sub_box(clientiMenuitem)
{      
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(iMenu)
        return 
PLUGIN_HANDLED
    
}
       
    switch( 
item )
    {
        case 
0:
        {
            
set_cvar_num("mp_friendlyfire"1)
            
set_hudmessage(random_num(1,250), random_num(1,255), random_num(1,256), -1.0, -1.006.012.0);
            
show_hudmessage(0"Gurad: %s - Active Box"szName);
            
ColorChat0GREEN"[Jailbreak]^1 Guard:^3 %s ^1- Active ^4Box"szNameclient ) );
        }
        
        case 
1:
        {
            
set_cvar_num("mp_friendlyfire"0)
            
set_hudmessage(random_num(1,255), random_num(1,255), random_num(1,255), -1.0, -1.006.012.0);
            
show_hudmessage(0"Gurad: %s - Disactived JailBreak Box",szName);
            
ColorChat0GREEN"[Jailbreak]^1 Guard:^3 %s ^1- Disactived ^4Box"szNameclient ) );
        }
        
        case 
2:
        {
                           new 
players32 ], pnum;
                           
get_playersplayerspnum"aceh""TERRORIST" );
                       
                           for(new 
0pnumi++)
                                       
fm_set_user_healthplayers[i], 100 );
 
                           
ColorChat0GREEN"[Jailbreak]^3 %s^1 has reseted HP To ^4Prisoner's^1 Team!"szNameclient ));
                        
                           
cmdBoxclient );
                           return 
PLUGIN_CONTINUE;
                }              
        }
 
        return 
PLUGIN_HANDLED;
}

public 
HamTakeDamagevictiminflictorattackerFloat:damagedamagebits )
{
        if ( (!
is_user_connectedattacker ) || !is_user_aliveattacker ))  && (!is_user_connectedvictim ) || !is_user_alivevictim ))
                return 
HAM_IGNORED;
       
        new 
Ateam fm_get_user_team(attacker)
        new 
Vteam fm_get_user_team(victim)
        if(
Ateam == CS_TEAM_CT && Vteam == CS_TEAM_CT)
                   return 
HAM_SUPERCEDE
        HAM_IGNORE
}

stock GetUserNameclient )
{
    static 
szName32 ];
    
    
get_user_nameclientszNamecharsmaxszName ) );
    
    return 
szName;



i got 2 error:

Code:

public HamTakeDamage( victim, inflictor, attacker, Float:damage, damagebits )
{
        if ( (!is_user_connected( attacker ) || !is_user_alive( attacker ))  && (!is_user_connected( victim ) || !is_user_alive( victim ) )
                return HAM_IGNORED;
     
        new Ateam = cs_get_user_team(attacker)
        new Vteam = cs_get_user_team(victim)
        if(Ateam == CS_TEAM_CT && Vteam == CS_TEAM_CT)
                  return HAM_SUPERCEDE
        HAM_IGNORE
}

why u add HAM_IGNORE line?
and i think u missed more )
in last line
Code:

!is_user_alive( victim ) )
>
Code:

!is_user_alive( victim ) ) )
Code:

Warning: Function "HamTakeDamage" should return a value

Natsheh 10-17-2014 06:12

Re: Jailbreak Box can kill each other CT
 
Quote:

Originally Posted by Fuck For Fun (Post 2211917)
i got 2 error:

Code:

public HamTakeDamage( victim, inflictor, attacker, Float:damage, damagebits )
{
        if ( (!is_user_connected( attacker ) || !is_user_alive( attacker ))  && (!is_user_connected( victim ) || !is_user_alive( victim ) )
                return HAM_IGNORED;
     
        new Ateam = cs_get_user_team(attacker)
        new Vteam = cs_get_user_team(victim)
        if(Ateam == CS_TEAM_CT && Vteam == CS_TEAM_CT)
                  return HAM_SUPERCEDE
        HAM_IGNORE
}

why u add HAM_IGNORE line?
and i think u missed more )
in last line
Code:

!is_user_alive( victim ) )
>
Code:

!is_user_alive( victim ) ) )
Code:

Warning: Function "HamTakeDamage" should return a value

alright i fixed it

Fuck For Fun 10-17-2014 10:31

Re: Jailbreak Box can kill each other CT
 
Quote:

Originally Posted by Natsheh (Post 2212053)
alright i fixed it

Line:
Code:

        new Vteam = fm_get_user_team(victim)
        if(Ateam == CS_TEAM_CT && Vteam == CS_TEAM_CT)

Quote:

Warning: Tag mismatch
Tag mismatch happens when something messy.

So I think the test of CT> CT can be done in a different way?

Natsheh 10-17-2014 11:17

Re: Jailbreak Box can kill each other CT
 
Quote:

Originally Posted by Fuck For Fun (Post 2212155)
Line:
Code:

        new Vteam = fm_get_user_team(victim)
        if(Ateam == CS_TEAM_CT && Vteam == CS_TEAM_CT)


Tag mismatch happens when something messy.

So I think the test of CT> CT can be done in a different way?

alright i fix it again and no its a good way

the code is too messy.... ( part messy fixed )
No more warnings! and no more error's!
Compiles fine...


All times are GMT -4. The time now is 17:35.

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