Raised This Month: $ Target: $400
 0% 

Help (Should be simple)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 06-06-2010 , 16:14   Help (Should be simple)
Reply With Quote #1

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?
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-06-2010 , 16:28   Re: Help (Should be simple)
Reply With Quote #2

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

RedRobster is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 06-06-2010 , 16:55   Re: Help (Should be simple)
Reply With Quote #3

Quote:
Originally Posted by RedRobster View Post
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.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-06-2010 , 17:21   Re: Help (Should be simple)
Reply With Quote #4

Use read_data(1) as the killer's id. But, make sure the killer/attacker is a player.
__________________
fysiks is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 06-06-2010 , 17:48   Re: Help (Should be simple)
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
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?
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-06-2010 , 19:11   Re: Help (Should be simple)
Reply With Quote #6

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.

Last edited by RedRobster; 06-06-2010 at 19:39.
RedRobster is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 06-06-2010 , 19:15   Re: Help (Should be simple)
Reply With Quote #7

You forgot get_players( );
__________________
Hi.
Kreation is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-06-2010 , 19:38   Re: Help (Should be simple)
Reply With Quote #8

Quote:
Originally Posted by Kreation View Post
You forgot get_players( );
**Face palm**

Last edited by RedRobster; 06-06-2010 at 19:46.
RedRobster is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 06-06-2010 , 21:07   Re: Help (Should be simple)
Reply With Quote #9

Quote:
Originally Posted by RedRobster View Post
**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 

PHP Code:
new bool:gShouldSwitch[32] = false 
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 06-06-2010 at 21:09.
GXLZPGX is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 06-06-2010 , 21:10   Re: Help (Should be simple)
Reply With Quote #10

PHP Code:
new bool:gShouldSwitch[33
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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