AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help (Should be simple) (https://forums.alliedmods.net/showthread.php?t=128897)

GXLZPGX 06-06-2010 16:14

Help (Should be simple)
 
I would like to set something up like this:

*If a CT kills a T, that CT switches places with that T
*If a T kills a CT, it adds 30 seconds to the timer, and they don't switch.

Any simple way of going about this?

RedRobster 06-06-2010 16:28

Re: Help (Should be simple)
 
PHP Code:

public plugin_init()
{
       
register_event"DeathMsg" "SwitchTeams" "a" )
}

public 
SwitchTeams()
{
       new 
iVictim read_data)
       new 
iAttacker get_user_attackeriVictim )

       if( 
iVictim == iAttacker )
               return 
PLUGIN_HANDLED

       
if( cs_get_user_teamiVictim ) == CS_TEAM_T )
       {
               
cs_set_user_teamiVictim CS_TEAM_CT )
               
cs_set_user_teamiAttacker CS_TEAM_T )
       }
       else if( 
cs_get_user_teamiVictim ) == CS_TEAM_CT )
       {
               
//Increase Timer (I'm not sure how to)
       
}
       return 
PLUGIN_HANDLED



GXLZPGX 06-06-2010 16:55

Re: Help (Should be simple)
 
Quote:

Originally Posted by RedRobster (Post 1201646)
PHP Code:

public plugin_init()
{
       
register_event"DeathMsg" "SwitchTeams" "a" )
}

public 
SwitchTeams()
{
       new 
iVictim read_data)
       new 
iAttacker get_user_attackeriVictim )

       if( 
iVictim == iAttacker )
               return 
PLUGIN_HANDLED

       
if( cs_get_user_teamiVictim ) == CS_TEAM_T )
       {
               
cs_set_user_teamiVictim CS_TEAM_CT )
               
cs_set_user_teamiAttacker CS_TEAM_T )
       }
       else if( 
cs_get_user_teamiVictim ) == CS_TEAM_CT )
       {
               
iTimer 30.0
       
}
       return 
PLUGIN_HANDLED



The timer is named iTimer so that should work. Thanks, I'll try it. I'll be sure to give you credit when I release the plugin publicly.

fysiks 06-06-2010 17:21

Re: Help (Should be simple)
 
Use read_data(1) as the killer's id. But, make sure the killer/attacker is a player.

GXLZPGX 06-06-2010 17:48

Re: Help (Should be simple)
 
Quote:

Originally Posted by fysiks (Post 1201738)
Use read_data(1) as the killer's id. But, make sure the killer/attacker is a player.

Alright. So now, I don't want them to switch instantly. I want it to switch the Killer and Victim at the end of the round. Example?

RedRobster 06-06-2010 19:11

Re: Help (Should be simple)
 
PHP Code:

new bool:gSwitchPlayer[32] = false

public plugin_init()
{
    
register_event"DeathMsg" "SwitchTeams" "a" )
      
}

public 
SwitchTeams()
{
    new 
iAttacker read_data)     
    new 
iVictim read_data)

    if( 
iVictim == iAttacker )
        return 
PLUGIN_HANDLED

    
if( cs_get_user_teamiVictim ) == CS_TEAM_T && !is_user_botiVictim ) )
    {
        
gShouldSwitch[iVictim] = true
        gShouldSwitch
[iAttacker] = true
    
}
    else if( 
cs_get_user_teamiVictim ) == CS_TEAM_CT && !is_user_botiVictim ) )
    {
        
iTimer 30.0
    
}
    return 
PLUGIN_HANDLED
}

public 
round_end(iTimer//Not sure, but I believe this is correct. Might not be though.
{
    new 
iPlayers[32], iNum
    get_players
iPlayersiNum )

    for( new 
iiNumi++ )
    {
        new 
id iPlayers[i]
        
        if( !
is_user_bot(id) && gShouldSwitch[id] == true )
        {
            if( 
cs_get_user_teamid ) == CS_TEAM_T )
            {
                
cs_set_user_teamid ) == CS_TEAM_CT
            
}
            else if( 
cs_get_user_teamid ) == CS_TEAM_CT )
            {
                
cs_set_user_teamid ) == CS_TEAM_T
            
}
        }
    }


That should do it. Maybe not the most effective way, but it should work.

Kreation 06-06-2010 19:15

Re: Help (Should be simple)
 
You forgot get_players( );

RedRobster 06-06-2010 19:38

Re: Help (Should be simple)
 
Quote:

Originally Posted by Kreation (Post 1201805)
You forgot get_players( );

**Face palm**

GXLZPGX 06-06-2010 21:07

Re: Help (Should be simple)
 
Quote:

Originally Posted by RedRobster (Post 1201821)
**Face palm**

Shouldn't I also add:

Undefined symbol gShouldSwitch

This should be it. You made the wrong bool:

PHP Code:

new bool:gSwitchPlayer[32] = false 

:arrow:
PHP Code:

new bool:gShouldSwitch[32] = false 


wrecked_ 06-06-2010 21:10

Re: Help (Should be simple)
 
PHP Code:

new bool:gShouldSwitch[33



All times are GMT -4. The time now is 05:26.

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