AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   /spec and /back plugin (https://forums.alliedmods.net/showthread.php?t=271067)

UZ@IR 09-04-2015 13:43

/spec and /back plugin
 
Hello guys
today i need a plugin that if we say: /spec we automaticlly go to spectate
and when we say /back we automatically join back

Thnx

indraraj striker 09-05-2015 00:55

Re: /spec and /back plugin
 
1 Attachment(s)
here you go :
PHP Code:

#include <amxmodx>
#include <cstrike>

public plugin_init() {
    
register_clcmd("say /spec","spec_transfer");
    
register_clcmd("say_team /spec","spec_transfer");
    
register_clcmd("say /back","back_transfer");
    
register_clcmd("say_team /back","back_transfer");
}

public 
spec_transfer(id)
{
    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
    {
        
cs_set_user_team(id,CS_TEAM_SPECTATOR);
        
user_silentkill(id);
    }
    else
    {
        
client_print(id,print_chat,"You are already on spectator");
    }
}

public 
back_transfer(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR)
    {
        new 
randrandom_num(1,2)
        switch(
rand)
        {
            case 
1:{
            
cs_set_user_team(id,CS_TEAM_CT);
            }
            
            case 
2:{
            
cs_set_user_team(id,CS_TEAM_T);
            }
        }
    }
    else
    {
        
client_print(id,print_chat,"you are not in spectator");
    }



UZ@IR 09-05-2015 04:09

Re: /spec and /back plugin
 
Thnx

crystal xtreme 07-02-2022 09:13

Re: /spec and /back plugin
 
nice :D

lexzor 07-02-2022 11:13

Re: /spec and /back plugin
 
PHP Code:

#include <amxmodx>
#include <cstrike>

new CsTeams:csLastTeam[MAX_PLAYERS 1];

public 
plugin_init() {
    
register_clcmd("say /spec","spec_transfer");
    
register_clcmd("say_team /spec","spec_transfer");
    
register_clcmd("say /back","back_transfer");
    
register_clcmd("say_team /back","back_transfer");
}

public 
client_connect(id) { csLastTeam[id] = CS_TEAM_UNASSIGNED; }

public 
spec_transfer(id)
{
    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
    {
        
cs_set_user_team(idCS_TEAM_SPECTATOR);
        
        if(
is_user_alive(id))
            
user_silentkill(id1);
        
        
csLastTeam[id] = cs_get_user_team(id);
    }
    else
    {
        
client_print(id,print_chat,"You are already on spectator");
    }
}

public 
back_transfer(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR)
    {
        
cs_set_user_team(idcsLastTeam[id]);
    }
    else
    {
        
client_print(id,print_chat,"you are not in spectator");
    }



crystal xtreme 07-02-2022 11:35

Re: /spec and /back plugin
 
You changed something?
i need to add admins only.
Just admins can use this command. Can you do this?
If normal player use this they will show this message: [Spec] Sorry, You don't have access to use this command.
I tryed and i think i made it Cheak this it's right or not:

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <cromchat>

public plugin_init() {
    
register_clcmd("say /spec","spec_transfer");
    
register_clcmd("say_team /spec","spec_transfer");
    
register_clcmd("say /back","back_transfer");
    
register_clcmd("say_team /back","back_transfer");
}

public 
spec_transfer(id)
{
    if(!(
get_user_flags(id) & ADMIN_KICK))
    {
        
CC_SendMessage(id"&x04[Spec] &x03Sorry&x01, &x03You don't have access to use this command.");
        
    return 
PLUGIN_HANDLED;
    }
    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
    {
        
cs_set_user_team(id,CS_TEAM_SPECTATOR);
        
user_silentkill(id);
    }
    else
    {
        
CC_SendMessage(id"&x04[Spec] &x03You are already on spectator");
    }
}

public 
back_transfer(id)
{
    if(!(
get_user_flags(id) & ADMIN_KICK))
    {
        
CC_SendMessage(id"&x04[Spec] &x03Sorry&x01, &x03You don't have access to use this command.");
        
    return 
PLUGIN_HANDLED;
    }
    if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR)
    {
        new 
randrandom_num(1,2)
        switch(
rand)
        {
            case 
1:{
            
cs_set_user_team(id,CS_TEAM_CT);
            }
            
            case 
2:{
            
cs_set_user_team(id,CS_TEAM_T);
            }
        }
    }
    else
    {
        
CC_SendMessage(id"&x04[Spec] &x03You are not in spectator");
    }



TribalBlood 07-02-2022 14:19

Re: /spec and /back plugin
 
PHP Code:

#include <amxmodx>
#include <cstrike>

public plugin_init()
{
    
register_plugin("ADMIN_SPEC_AND_BACK""1.0""TribalBlood");
    
register_clcmd("say /spec""spectator_transfer");
}

public 
spectator_transfer(id)
{
    if(!(
get_user_flags(id) & ADMIN_KICK))
    {
        return 
PLUGIN_HANDLED;
    }

    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
    {
        if(
is_user_alive(id))
        {
            
user_silentkill(id1);
            
cs_set_user_team(idCS_TEAM_SPECTATOR);
        }
        else
        {
            
cs_set_user_team(idCS_TEAM_SPECTATOR);
        }
    }
    else
    {
        switch(
random_num(12))
        {
            case 
1:
            {
                
cs_set_user_team(idCS_TEAM_T);
            }
            case 
2:
            {
                
cs_set_user_team(idCS_TEAM_CT);
            }
        }
    }

    return 
PLUGIN_HANDLED;



Napoleon_be 07-02-2022 17:35

Re: /spec and /back plugin
 
Quote:

Originally Posted by lexzor (Post 2782902)
PHP Code:

#include <amxmodx>
#include <cstrike>

new CsTeams:csLastTeam[MAX_PLAYERS 1];

public 
plugin_init() {
    
register_clcmd("say /spec","spec_transfer");
    
register_clcmd("say_team /spec","spec_transfer");
    
register_clcmd("say /back","back_transfer");
    
register_clcmd("say_team /back","back_transfer");
}

public 
client_connect(id) { csLastTeam[id] = CS_TEAM_UNASSIGNED; }

public 
spec_transfer(id)
{
    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
    {
        
cs_set_user_team(idCS_TEAM_SPECTATOR);
        
        if(
is_user_alive(id))
            
user_silentkill(id1);
        
        
csLastTeam[id] = cs_get_user_team(id);
    }
    else
    {
        
client_print(id,print_chat,"You are already on spectator");
    }
}

public 
back_transfer(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR)
    {
        
cs_set_user_team(idcsLastTeam[id]);
    }
    else
    {
        
client_print(id,print_chat,"you are not in spectator");
    }



You should store the current team in csLastTeam[] before switching the player to spectator.

lexzor 07-02-2022 18:49

Re: /spec and /back plugin
 
Quote:

Originally Posted by Napoleon_be (Post 2782929)
You should store the current team in csLastTeam[] before switching the player to spectator.

you are right

PHP Code:

#include <amxmodx>
#include <cstrike>

#define ADMIN_FLAG "c"
#define CHAT_PREFIX "^4[^3TAG^4]^1"

new CsTeams:csLastTeam[MAX_PLAYERS 1];

public 
plugin_init()
{
    
register_plugin("Back""1.0""AM");

    
register_clcmd("say /spec","spec_transfer");
    
register_clcmd("say_team /spec","spec_transfer");
    
register_clcmd("say /back","back_transfer");
    
register_clcmd("say_team /back","back_transfer");
}

public 
client_connect(id) { csLastTeam[id] = CS_TEAM_UNASSIGNED; }

public 
spec_transfer(id)
{
    if(!
isok(id))
        return 
PLUGIN_HANDLED;

    new 
CsTeams:csTeam cs_get_user_team(id);

    if(
csTeam != CS_TEAM_SPECTATOR)
    {
        
csLastTeam[id] = csTeam;
        
cs_set_user_team(idCS_TEAM_SPECTATOR);
        
        if(
is_user_alive(id))
            
user_silentkill(id1);

        
client_print_color(idprint_team_default"%s You have been moved to^4 Spectator^1 team"CHAT_PREFIX);
    }
    else 
client_print_color(idprint_team_default"%s You are already in^4 Spectator^1 team!");

    return 
PLUGIN_HANDLED;
}

public 
back_transfer(id)
{
    if(!
isok(id))
        return 
PLUGIN_HANDLED;

    if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR)
    {
        
cs_set_user_team(idcsLastTeam[id]);
        
client_print_color(idprint_team_default"%s You have been moved to^4 %s^1 team"CHAT_PREFIXcsLastTeam[id] == CS_TEAM_T "Terrorist" "Counter-Terrorist");
    }
    else 
client_print_color(idprint_team_default"%s You must be in^4 Spectator^1 team!");

    return 
PLUGIN_HANDLED;


stock bool:isok(id)
{
    if(!(
get_user_flags(id) & read_flags(ADMIN_FLAG)))
        return 
true;
    
    
client_print_color(idprint_team_default"%s You must be an^4 admin^1 to use this command!"CHAT_PREFIX);
    return 
false


/back command will move back into your last team before using /spec command. you can change admin acces and tag chat

OciXCrom 07-03-2022 07:17

Re: /spec and /back plugin
 
https://www.amxx-bg.info/forum/viewt...hp?f=21&t=1114


All times are GMT -4. The time now is 02:12.

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