View Single Post
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