AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Dead Switch Team Plugin (https://forums.alliedmods.net/showthread.php?t=344392)

Ace67 11-02-2023 06:45

Dead Switch Team Plugin
 
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.

Ace67 11-02-2023 11:08

Re: Dead Switch Team Plugin
 
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;



Ace67 04-19-2024 15:43

Re: Dead Switch Team Plugin
 
bump, if someone can still help me about it.

tedaimlocks 04-19-2024 16:58

Re: Dead Switch Team Plugin
 
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");
        }
    }
}


Ace67 04-19-2024 17:37

Re: Dead Switch Team Plugin
 
Quote:

Originally Posted by tedaimlocks (Post 2821224)
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.

tedaimlocks 04-20-2024 00:56

Re: Dead Switch Team Plugin
 
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");
        }
    }
}


Ace67 04-20-2024 08:42

Re: Dead Switch Team Plugin
 
Quote:

Originally Posted by tedaimlocks (Post 2821236)
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

tedaimlocks 04-20-2024 13:12

Re: Dead Switch Team Plugin
 
1 Attachment(s)
Quote:

Originally Posted by Ace67 (Post 2821257)
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!

Ace67 04-20-2024 18:06

Re: Dead Switch Team Plugin
 
Quote:

Originally Posted by tedaimlocks (Post 2821270)
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


All times are GMT -4. The time now is 23:46.

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