Raised This Month: $39 Target: $400
 9% 

/spec and /back plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[email protected]
Member
Join Date: Sep 2014
Old 09-04-2015 , 14:43   /spec and /back plugin
Reply With Quote #1

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
UZ@IR is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 09-05-2015 , 01:55   Re: /spec and /back plugin
Reply With Quote #2

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");
    }

Attached Files
File Type: sma Get Plugin or Get Source (spec.sma - 1375 views - 837 Bytes)
indraraj striker is offline
[email protected]
Member
Join Date: Sep 2014
Old 09-05-2015 , 05:09   Re: /spec and /back plugin
Reply With Quote #3

Thnx
UZ@IR is offline
crystal xtreme
Member
Join Date: Sep 2021
Location: Pakistan, Karachi.
Old 07-02-2022 , 10:13   Re: /spec and /back plugin
Reply With Quote #4

nice

Last edited by crystal xtreme; 07-02-2022 at 10:36.
crystal xtreme is offline
lexzor
Senior Member
Join Date: Nov 2020
Old 07-02-2022 , 12:13   Re: /spec and /back plugin
Reply With Quote #5

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");
    }


Last edited by lexzor; 07-02-2022 at 12:14.
lexzor is offline
crystal xtreme
Member
Join Date: Sep 2021
Location: Pakistan, Karachi.
Old 07-02-2022 , 12:35   Re: /spec and /back plugin
Reply With Quote #6

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");
    }


Last edited by crystal xtreme; 07-02-2022 at 12:36.
crystal xtreme is offline
TribalBlood
Member
Join Date: Oct 2020
Location: Defqon.1
Old 07-02-2022 , 15:19   Re: /spec and /back plugin
Reply With Quote #7

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;

__________________
TribalBlood is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-02-2022 , 18:35   Re: /spec and /back plugin
Reply With Quote #8

Quote:
Originally Posted by lexzor View Post
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.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
lexzor
Senior Member
Join Date: Nov 2020
Old 07-02-2022 , 19:49   Re: /spec and /back plugin
Reply With Quote #9

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

Last edited by lexzor; 07-02-2022 at 19:50.
lexzor is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-03-2022 , 08:17   Re: /spec and /back plugin
Reply With Quote #10

https://www.amxx-bg.info/forum/viewt...hp?f=21&t=1114
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

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 09:40.


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