AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Changing Teams Help! (https://forums.alliedmods.net/showthread.php?t=213417)

oxygen935 04-14-2013 14:29

Changing Teams Help!
 
Hey i have a problem...
I want a plugin for my deathmatch server... But its complicated...
I want when a CT Kills a T:
-The CT next round Will be moved to T
-The T next round Will be moved to CT

I have this code but is bugged...
I mean when CT Kills T: the CT next round moved to T but the T isn't moved to CT

Code for fixing:
PHP Code:

#include <amxmodx>
#include <cstrike>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "oxygen"

new nextct[33]
new 
nextt[33]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg""Event_DeathMsg""a")
    
register_logevent("logevent_round_end"2"1=Round_End"
}
public 
Event_DeathMsg()
{
    new 
iKiller read_data(1)
    new 
iVictim read_data(2)
    
    new 
killername[33], victimname[33]
    
get_user_name(iKiller,killername,32)
    
get_user_name(iVictim,victimname,32)
    
    switch(
cs_get_user_team(iVictim))
    {
        case 
CS_TEAM_T:
        {
            
nextct[iVictim] = true
            nextt
[iKiller] = true
        
}
    }
}

public 
logevent_round_end()
{
    new 
players[32], pnumtempid
    get_players
(playerspnum"a"); 
    for( new 
ii<pnumi++ ) 
    { 
        
tempid players[i];
        if(
nextt[tempid])
        {
            
cs_set_user_team(tempidCS_TEAM_T)
        }
        if(
nextct[tempid])
        {
            
cs_set_user_team(tempidCS_TEAM_CT)
        }
    }



wickedd 04-14-2013 15:00

Re: IMPORTANT plz help!
 
If it's so IMPORTANT search the forum, this has been discuss many times.

oxygen935 04-14-2013 15:03

Re: IMPORTANT plz help!
 
i searched man... And the only thing i found is Team Swap...
It's so difficult to help?? :/

wickedd 04-14-2013 15:07

Re: IMPORTANT plz help!
 
Is it so difficult to post a descriptive title? Beside, if you search the forum you will find a working code that does what you want.

oxygen935 04-14-2013 15:11

Re: IMPORTANT plz help!
 
And again... If you have a topic that do what i want to do with this plugin(cause i can't find) post the topic here or gimme a keyword to search...

Blizzard_87 04-14-2013 16:51

Re: IMPORTANT plz help!
 
to edit title. click edit on your first post then click go advanced.

Blizzard_87 04-14-2013 20:18

Re: not important, don't open me
 
i dont know if this is correct but i tested with bots and when you kill someone what ever team they were on they switch next round... and you also switch on next round....

and if you didnt kill anyone then you dont switch...

this what you want?

PHP Code:

#include <amxmodx> 
#include <cstrike> 

#define PLUGIN "New Plug-In" 
#define VERSION "1.0" 
#define AUTHOR "oxygen" 

new NRTS[33] = false;

public 
plugin_init()  

    
register_plugin(PLUGINVERSIONAUTHOR
    
register_event("DeathMsg""Event_DeathMsg""a"
    
register_logevent("logevent_round_end"2"1=Round_End")  

public 
Event_DeathMsg() 

    new 
iKiller read_data(1
    new 
iVictim read_data(2
    
    
NRTS[iKiller] = true;
    
NRTS[iVictim] = true;
    
set_task(1.0"Change_Teams"iVictim)


public 
logevent_round_end() 

    new 
players[32], pnumtempid 
    get_players
(playerspnum"ac""CT");  
    for( new 
0i<pnumi++ )  
    {  
        
tempid players[i]; 
        
        
set_task(1.0"Change_Teams"tempid)
    } 
}  

public 
Change_Teams(id)
{
    if(
NRTS[id])
    {
        switch(
cs_get_user_team(id))
        {
            case 
CS_TEAM_CTcs_set_user_team(idCS_TEAM_T);
            case 
CS_TEAM_Tcs_set_user_team(idCS_TEAM_CT);
        }
    }



oxygen935 04-15-2013 00:47

Re: not important, don't open me
 
I only want to change teams when CT Kills T but when T Kills CT not changing teams...

Blizzard_87 04-15-2013 00:52

Re: Changing Teams Help!
 
ok. you should be able to edit it. but if not ill change it when I get on computer.

Kard1nal 04-15-2013 04:23

Re: Changing Teams Help!
 
Code:
#include <amxmodx> #include <cstrike> #include <hamsandwich> new bool:T[33], bool:CT[33] public plugin_init() {     RegisterHam(Ham_Killed, "player", "player_killed", 1)     register_logevent("round_start", 2, "0=World triggered", "1=Round_Start") } public player_killed(victim, attacker, shouldgib) {     if(victim == attacker || get_user_team(attacker) != 2 || get_user_team(victim) != 1)         return HAM_IGNORED             T[attacker] = true     CT[victim] = true     return HAM_IGNORED } public client_disconnect(id) {     T[id] = false     CT[id] = false } public round_start() {     new Players[32], num, i     get_players(Players, num, "a")     for(i = 0; i < num; i++)     {         if(T[Players[i]])         {             cs_set_user_team(Players[i], CS_TEAM_T)             T[Players[i]] = false         }         else if(CT[Players[i]])         {             cs_set_user_team(Players[i], CS_TEAM_CT)             CT[Players[i]] = false         }     } }


All times are GMT -4. The time now is 10:54.

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