Raised This Month: $32 Target: $400
 8% 

/spec and /back plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
UZ@IR
Member
Join Date: Sep 2014
Old 09-04-2015 , 13: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 , 00: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 - 1692 views - 837 Bytes)
indraraj striker is offline
UZ@IR
Member
Join Date: Sep 2014
Old 09-05-2015 , 04: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 , 09:13   Re: /spec and /back plugin
Reply With Quote #4

nice

Last edited by crystal xtreme; 07-02-2022 at 09:36.
crystal xtreme is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-02-2022 , 11: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 11:14.
lexzor is offline
crystal xtreme
Member
Join Date: Sep 2021
Location: Pakistan, Karachi.
Old 07-02-2022 , 11: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 11:36.
crystal xtreme is offline
TribalBlood
Member
Join Date: Oct 2020
Old 07-02-2022 , 14: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;

__________________
My Steam Profile

- Online Rarely -
TribalBlood is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-02-2022 , 17: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 online now
Send a message via Skype™ to Napoleon_be
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-02-2022 , 18: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 18:50.
lexzor is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-03-2022 , 07: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



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 07:33.


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