Raised This Month: $51 Target: $400
 12% 

Dead Switch Team Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 11-02-2023 , 06:45   Dead Switch Team Plugin
Reply With Quote #1

Yo, i made this plugin for switch all dead CT to T on last round before change map for basebuilder

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <fun>
#include <csstats>
#include <csx>
#include <xs>

public plugin_init() {
    
register_plugin("Switch Dead CT to T on Last Round""1.0""Ace67");
    
register_event("Round_End""round_end_event""a""1=1");
}

public 
round_end_event(id) {
    if (
cs_get_user_team(id) == CS_TEAM_CT && !is_user_alive(id)) {
        
cs_set_user_team(idCS_TEAM_T);
        
client_print(idprint_chat"You have been moved to the Terrorist team for the last round.");
        
Respawn_Zombie(id);
    }
}

public 
Respawn_Zombie(id) {
    if (
is_user_connected(id) && cs_get_user_team(id) == CS_TEAM_T) {
        if (
get_user_health(id) == 6500 || !is_user_alive(id)) {
            
ExecuteHamB(Ham_CS_RoundRespawnid);
        } else {
            
client_print(idprint_center"%L"LANG_SERVER"FAIL_RESPAWN");
        }
    }

Got error:
PHP Code:
L 11/02/2023 15:17:54Invalid event (name "Round_End") (plugin "lastround.amxx")
L 11/02/2023 15:17:54: [AMXXDisplaying debug trace (plugin "lastround.amxx"version "1.0")
L 11/02/2023 15:17:54: [AMXXRun time error 10native error (native "register_event")
L 11/02/2023 15:17:54: [AMXX]    [0lastround.sma::plugin_init (line 14
I'm using the function respawn from basebuilder so that's not affecting it.
__________________
CS:CZ > CS 1.6

Last edited by Ace67; 11-02-2023 at 10:21.
Ace67 is offline
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 11-02-2023 , 11:08   Re: Dead Switch Team Plugin
Reply With Quote #2

I found a others method for it but i would its automatic. I made on this when they are dead admin need to type bb_swap deadct on the console and it will switch. But if someone can do it automatic at last round instead of typing. (For the last round map) 6 of 6

PHP Code:
public cmdSwap(id)
{
    if (
access(idSWAP))
    {
        new 
arg[32];
        
read_argv(1arg31);

        if (
equal(arg"deadct"true))
        {
            new 
hasDeadCT false
            
            new 
player;
            for (
player 1player <= get_maxplayers(); player++)
            {
                if (
is_user_connected(player) && cs_get_user_team(player) == CS_TEAM_CT && !is_user_alive(player))
                {
                    
// Switch the dead CT player to the terrorist team
                    
cs_set_user_team(playerCS_TEAM_T);
                    
                    
// Respawn the player as a Zombie
                    
Respawn_Zombie(player);
                    
                    
hasDeadCT true;
                    
                    
client_print(playerprint_chat"[BaseBuilder] You have been moved to the Terrorist team for the last round.");
                }
            }
            
            if (!
hasDeadCT)
            {
                
// Print msg
                
client_print(idprint_console"[Swap] There are no dead players on CT!");
                return 
PLUGIN_HANDLED;
            }
            
            
// Log and print a message indicating the action
            
new adminname[35];
            
get_user_name(idadminname34);
            
Log("[TEAM-SWAP-DEADCT] Admin: %s switched dead CT players to Terrorist team and respawned them as Zombies"adminname);
            
client_print(idprint_console"[Swap] You switched all dead Builder players to Zombies.");
        }
        else
        {
            new 
player cmd_target(idargCMDTARGET_OBEY_IMMUNITY);
            
            if (!
is_user_connected(player)) return PLUGIN_HANDLED;
            
            
cs_set_user_team(playercs_get_user_team(player) == CS_TEAM_T CS_TEAM_CT CS_TEAM_T);
            
            if (
cs_get_user_team(player) == CS_TEAM_T)
            {
                
g_iszombie[player] = true;
                
g_ishuman[player] = false;
            }
            if (
cs_get_user_team(player) == CS_TEAM_CT)
            {
                
g_ishuman[player] = true;
                
g_iszombie[player] = false;
            }
            
            if (
is_user_alive(player))
                
ExecuteHamB(Ham_CS_RoundRespawnplayer);
            
            
// Print a message to the switched player
            
client_print(playerprint_chat"[BaseBuilder] You've been changed to the other team by an admin!");
            
            new 
adminname[35], playername[35];
            
get_user_name(idadminname34);
            
get_user_name(playerplayername34); 
            
Log("[TEAM-SWAP] Admin: %s swapped Player: %s"adminnameplayername);
            
            
client_print(idprint_console"[Swap] Player %s has been switched to the opposite team."playername);
        }
    }
    return 
PLUGIN_HANDLED;

__________________
CS:CZ > CS 1.6

Last edited by Ace67; 04-19-2024 at 17:46.
Ace67 is offline
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 04-19-2024 , 15:43   Re: Dead Switch Team Plugin
Reply With Quote #3

bump, if someone can still help me about it.
__________________
CS:CZ > CS 1.6
Ace67 is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 04-19-2024 , 16:58   Re: Dead Switch Team Plugin
Reply With Quote #4

Try this

HTML Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public plugin_init() {
    register_plugin("Switch Dead CT to T on Last Round", "1.0", "Ace67");
    register_logevent("logevent_RoundEnd", 2, "1=Round_End");
}

public logevent_RoundEnd(id) 
    if (cs_get_user_team(id) == CS_TEAM_CT && !is_user_alive(id)) {
        cs_set_user_team(id, CS_TEAM_T);
        client_print(id, print_chat, "You have been moved to the Terrorist team for the last round.");
        Respawn_Zombie(id);
    }

public Respawn_Zombie(id) {
    if (is_user_connected(id) && cs_get_user_team(id) == CS_TEAM_T) {
        if (get_user_health(id) == 6500 || !is_user_alive(id)) {
            ExecuteHamB(Ham_CS_RoundRespawn, id);
        } else {
            client_print(id, print_center, "%L", LANG_SERVER, "FAIL_RESPAWN");
        }
    }
} 

Last edited by tedaimlocks; 04-19-2024 at 17:05.
tedaimlocks is offline
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 04-19-2024 , 17:37   Re: Dead Switch Team Plugin
Reply With Quote #5

Quote:
Originally Posted by tedaimlocks View Post
Try this

HTML Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public plugin_init() {
    register_plugin("Switch Dead CT to T on Last Round", "1.0", "Ace67");
    register_logevent("logevent_RoundEnd", 2, "1=Round_End");
}

public logevent_RoundEnd(id) 
    if (cs_get_user_team(id) == CS_TEAM_CT && !is_user_alive(id)) {
        cs_set_user_team(id, CS_TEAM_T);
        client_print(id, print_chat, "You have been moved to the Terrorist team for the last round.");
        Respawn_Zombie(id);
    }

public Respawn_Zombie(id) {
    if (is_user_connected(id) && cs_get_user_team(id) == CS_TEAM_T) {
        if (get_user_health(id) == 6500 || !is_user_alive(id)) {
            ExecuteHamB(Ham_CS_RoundRespawn, id);
        } else {
            client_print(id, print_center, "%L", LANG_SERVER, "FAIL_RESPAWN");
        }
    }
} 
doesnt work ..., because the basebuilder using already a swap things, so maybe if you can help to make it work with the code I sent up with "public cmdSwap(id)"

Or maybe a code, which I need to add into my basebuilder code for make it work.
__________________
CS:CZ > CS 1.6

Last edited by Ace67; 04-19-2024 at 17:56.
Ace67 is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 04-20-2024 , 00:56   Re: Dead Switch Team Plugin
Reply With Quote #6

I think this will maybe work

HTML Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public plugin_init() {
    register_plugin("Switch Dead CT to T on Last Round", "1.0", "Ace67");
    register_logevent("logevent_RoundEnd", 2, "1=Round_End");
}

public logevent_RoundEnd() 
    set_task(1.0, "CheckDead");

public CheckDead(id) {
    if (cs_get_user_team(id) == CS_TEAM_CT && !is_user_alive(id)) {
        cs_set_user_team(id, CS_TEAM_T);
        client_print(id, print_chat, "You have been moved to the Terrorist team for the last round.");
        Respawn_Zombie(id);
    }
}
public Respawn_Zombie(id) {
    if (is_user_connected(id) && cs_get_user_team(id) == CS_TEAM_T) {
        if (get_user_health(id) == 6500 || !is_user_alive(id)) {
            ExecuteHamB(Ham_CS_RoundRespawn, id);
        } else {
            client_print(id, print_center, "%L", LANG_SERVER, "FAIL_RESPAWN");
        }
    }
} 
tedaimlocks is offline
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 04-20-2024 , 08:42   Re: Dead Switch Team Plugin
Reply With Quote #7

Quote:
Originally Posted by tedaimlocks View Post
I think this will maybe work

HTML Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public plugin_init() {
    register_plugin("Switch Dead CT to T on Last Round", "1.0", "Ace67");
    register_logevent("logevent_RoundEnd", 2, "1=Round_End");
}

public logevent_RoundEnd() 
    set_task(1.0, "CheckDead");

public CheckDead(id) {
    if (cs_get_user_team(id) == CS_TEAM_CT && !is_user_alive(id)) {
        cs_set_user_team(id, CS_TEAM_T);
        client_print(id, print_chat, "You have been moved to the Terrorist team for the last round.");
        Respawn_Zombie(id);
    }
}
public Respawn_Zombie(id) {
    if (is_user_connected(id) && cs_get_user_team(id) == CS_TEAM_T) {
        if (get_user_health(id) == 6500 || !is_user_alive(id)) {
            ExecuteHamB(Ham_CS_RoundRespawn, id);
        } else {
            client_print(id, print_center, "%L", LANG_SERVER, "FAIL_RESPAWN");
        }
    }
} 
It gives error, so doesnt work

I made a new topic, which it will be better https://forums.alliedmods.net/showthread.php?t=347351
__________________
CS:CZ > CS 1.6

Last edited by Ace67; 04-20-2024 at 12:10.
Ace67 is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 04-20-2024 , 13:12   Re: Dead Switch Team Plugin
Reply With Quote #8

Quote:
Originally Posted by Ace67 View Post
It gives error, so doesnt work

I made a new topic, which it will be better https://forums.alliedmods.net/showthread.php?t=347351
It doesnt give any errors for me though.

"AMX Mod X 1.8.1" Compilation successfull!
Attached Files
File Type: sma Get Plugin or Get Source (code.sma - 12 views - 926 Bytes)
tedaimlocks is offline
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 04-20-2024 , 18:06   Re: Dead Switch Team Plugin
Reply With Quote #9

Quote:
Originally Posted by tedaimlocks View Post
It doesnt give any errors for me though.

"AMX Mod X 1.8.1" Compilation successfull!
it gives error in console. I just made a new topic https://forums.alliedmods.net/showthread.php?t=347351
__________________
CS:CZ > CS 1.6

Last edited by Ace67; 04-20-2024 at 18:08.
Ace67 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 06:45.


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