Raised This Month: $ Target: $400
 0% 

SwichSpecTeam problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LithuanianJack
Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
Old 08-31-2016 , 06:40   SwichSpecTeam problem
Reply With Quote #1

Hello. SwichSpecTeam plugin created to public server, but I used this in my CSDM server and when I type /spec I join to spectator team, but I can't go back to terrorists or counter-terrorists with M button. I must wait one round and then I can change team

Can anyone edit this plugin for CSDM server?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

new bool:TerroristTeam[33];

new 
CountTime[33];

new 
SpecTimes;

public 
plugin_init() {
    
register_plugin("Spec and Back command (Admins)""v1.2""kramesa");
    
    
register_clcmd("say /spec""cmdSpec");
    
register_clcmd("""cmdBack");  
    
    
SpecTimes register_cvar("amx_spectimes""10");
}

public 
cmdSpec(id) {
    if(
is_user_admin(id)) {
        new 
pCvarSpecTimes
        pCvarSpecTimes 
get_pcvar_num(SpecTimes);
        
        if(
CountTime[id] >= pCvarSpecTimes) {
            
client_print_color(idprint_chat"^4[/spec]^1 You can't use this command %d times!"pCvarSpecTimes);
            return 
PLUGIN_HANDLED;
        }
        
        if(
cs_get_user_team(id) == CS_TEAM_T){
            
TerroristTeam[id] = true;
        }
        else {
            
TerroristTeam[id] = false;
        }
        
        if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR) {
            
client_print_color(idprint_chat"^4[/spec]^1 You already a spectator");
            return 
PLUGIN_HANDLED;
        }
        else {
            
cs_set_user_team(idCS_TEAM_SPECTATOR);
            
user_kill(id1);
            
client_print_color(idprint_chat"^4[/spec]^1 You joined spectator team");
            
CountTime[id]++;
            return 
PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_HANDLED;
}

public 
cmdBack(id)
{
    if(
is_user_admin(id)) {
        if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
            
client_print_color(idprint_chat"^4[/spec]^1 You aren't spectator");
            return 
PLUGIN_HANDLED;
        }
        
        if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR) {
            if(
TerroristTeam[id] == true) {
                
cs_set_user_team(idCS_TEAM_T);
                
client_print_color(idprint_chat"^4[/spec]^1 You joined a terrorist team");
                return 
PLUGIN_HANDLED;
            }
            else {
                
cs_set_user_team(idCS_TEAM_CT);
                
client_print_color(idprint_chat"^4[/spec]^1 You joined a counter-terrorist team");
                return 
PLUGIN_HANDLED;
            }
            
ExecuteHam(Ham_CS_RoundRespawnid); 
            
cs_set_user_deaths(id0);
        }
    }
    return 
PLUGIN_HANDLED;
}

stock ChatColor(const id, const szMessage[], any:...)
{
    static 
szMsg[190], IdMsg;
    
vformat(szMsgcharsmax(szMsg), szMessage3);
    
    if(!
IdMsgIdMsg get_user_msgid("SayText");
    
    
message_begin(MSG_ONEIdMsg, .player id);
    
write_byte(id);
    
write_string(szMsg);
    
message_end();

Very sorry for my bad English
LithuanianJack is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-31-2016 , 11:22   Re: SwichSpecTeam problem
Reply With Quote #2

My version of what you want. Untested though

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>

#define PLUGIN "Switch Spec"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new pCvarSpecCounts

new iTransfers[33]
new 
CsTeams:iOldTeam[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /spec""CmdTransfer")
    
    
pCvarSpecCounts register_cvar("amx_spectimes""10")
}

public 
CmdTransfer(id) {
    if(
is_user_admin(id)) {
        new 
limit get_pcvar_num(pCvarSpecCounts)
        
        
iOldTeam[id] = cs_get_user_team(id)
        
        if(
iTransfers[id] >= limit) {
            
ColorChat(idGREEN"[/spec]^1 You can't use this command no more than %i times!"limit)
            return 
PLUGIN_HANDLED
        
}
        
        switch(
iOldTeam[id]) {
            case 
CS_TEAM_TSwitchToSpec(id)
            case 
CS_TEAM_CTSwitchToSpec(id)
            case 
CS_TEAM_SPECTATORSwitchBack(id)
            case 
CS_TEAM_UNASSIGNEDColorChat(idGREEN"[/spec]^1 You must be assigned to use this command.")
        }
    }
    return 
PLUGIN_HANDLED
}

public 
SwitchToSpec(id) {
    
user_kill(id)
    
ColorChat(idGREEN"[/spec]^1 You joined spectator team.")
    
cs_set_user_team(idCS_TEAM_SPECTATOR)
    
    
iTransfers[id]++
}

public 
SwitchBack(id) {
    
user_kill(id)
    
ColorChat(idGREEN"[/spec]^1 You joined back to your old team.")
    
cs_set_user_team(idiOldTeam[id])

__________________

Last edited by Napoleon_be; 09-01-2016 at 08:55.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
LithuanianJack
Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
Old 09-01-2016 , 12:01   Re: SwichSpecTeam problem
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
My version of what you want. Untested though

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>

#define PLUGIN "Switch Spec"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new pCvarSpecCounts

new iTransfers[33]
new 
CsTeams:iOldTeam[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /spec""CmdTransfer")
    
    
pCvarSpecCounts register_cvar("amx_spectimes""10")
}

public 
CmdTransfer(id) {
    if(
is_user_admin(id)) {
        new 
limit get_pcvar_num(pCvarSpecCounts)
        
        
iOldTeam[id] = cs_get_user_team(id)
        
        if(
iTransfers[id] >= limit) {
            
ColorChat(idGREEN"[/spec]^1 You can't use this command no more than %i times!"limit)
            return 
PLUGIN_HANDLED
        
}
        
        switch(
iOldTeam[id]) {
            case 
CS_TEAM_TSwitchToSpec(id)
            case 
CS_TEAM_CTSwitchToSpec(id)
            case 
CS_TEAM_SPECTATORSwitchBack(id)
            case 
CS_TEAM_UNASSIGNEDColorChat(idGREEN"[/spec]^1 You must be assigned to use this command.")
        }
    }
    return 
PLUGIN_HANDLED
}

public 
SwitchToSpec(id) {
    
user_kill(id)
    
ColorChat(idGREEN"[/spec]^1 You joined spectator team.")
    
cs_set_user_team(idCS_TEAM_SPECTATOR)
    
    
iTransfers[id]++
}

public 
SwitchBack(id) {
    
user_kill(id)
    
ColorChat(idGREEN"[/spec]^1 You joined back to your old team.")
    
cs_set_user_team(idiOldTeam[id])

Thanks, it works! But incompletely. When I go to the /spec (spectators) and come back, I have to wait for next raund when I can play. This is uncharacteristic to CSDM server.

I will wait for your answer if you understand what I wanted to say
LithuanianJack is offline
7thSense
Member
Join Date: Jul 2016
Old 09-01-2016 , 13:20   Re: SwichSpecTeam problem
Reply With Quote #4

Try this
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <colorchat>

#define PLUGIN "Spec Switch"
#define VERSION "0.1.3"
#define AUTHOR "many"

new CsTeams:zTeam[33]
new 
zDeath[33]
new 
bool:type_spec[33] = false
new g_cvar

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
/* Cvar */
    
g_cvar    register_cvar("amx_specmode",    "0")     // 0 - enable use to all, 1 - enable use only ADMINs
    /* Client Commands */
    
register_clcmd("say /spec",         "cmdSpec"ADMIN_ALL"- go to spectator")
    
register_clcmd("say_team /spec",     "cmdSpec"ADMIN_ALL"- go to spectator")
    
register_clcmd("say /back",         "cmdBack"ADMIN_ALL"- go back to your team")
    
register_clcmd("say_team /back",     "cmdBack"ADMIN_ALL"- go back to your team")
}

public 
cmdSpec(id)
{
    if(!
get_pcvar_num(g_cvar)) Spec(id)
    else if( 
get_pcvar_num(g_cvar) && (get_user_flags(id) & ADMIN_KICK)) Spec(id)
    else if( 
get_pcvar_num(g_cvar) && !(get_user_flags(id) & ADMIN_KICK)) PrintUserNotAdmin(id)
}

public 
cmdBack(id)
{
    if (
type_spec[id] && cs_get_user_team(id) == CS_TEAM_SPECTATOR && zTeam[id] != CS_TEAM_SPECTATOR Back(id)
    else if( 
get_pcvar_num(g_cvar) && !(get_user_flags(id) & ADMIN_KICK) ) PrintUserNotAdmin(id)
}

public 
Spec(id)
{
    
zDeath[id] = cs_get_user_deaths(id)
    if (
cs_get_user_team(id) == CS_TEAM_SPECTATOR)
    return
    else{
        
type_spec[id] = true
        zTeam
[id] = cs_get_user_team(id)
        
cs_set_user_team(idCS_TEAM_SPECTATOR)
        
user_silentkill(id)
        
ColorChat(idGREY,"^4[^3prafix^4]^3Type ^4/back ^3to return from ^4Spectator")
    }
    return
}

public 
Back(id)
{
    
cs_set_user_team(idzTeam[id])
    
cs_set_user_deaths(idzDeath[id])
    
set_task(0.5,"FirstRespawn",id)
    
set_task(0.8,"SecondRespawn",id)
}

public 
FirstRespawn(id)
{
    
cs_user_spawn(id)
}

public 
SecondRespawn(id)
{
    
cs_user_spawn(id)
    if (
cs_get_user_team(id) == CS_TEAM_T){
        
give_item(id,"weapon_knife")
    }
    if (
cs_get_user_team(id) == CS_TEAM_CT){
        
give_item(id,"weapon_knife")
    }
}

PrintUserNotAdmin(id)
{
    
ColorChat(idGREY,"^4[^3prefix^4]^3Only ^4Admins ^3can use ^4/spec, /back ^3command")
}

public 
PrintRule(id)
{
    if ( 
is_user_connected(id) && !is_user_bot(id) && !is_user_hltv(id) ){
        
ColorChat(idGREY,"^4[^3prefix^4]^3 Type ^4/spec ^3if you want to go ^4Spectator")
        
ColorChat(idGREY,"^4[^3prefix^4]^3 Type ^4/back ^3to return from ^4Spectator")
    }
}

public 
client_putinserver(id)
{
    if(!
get_pcvar_num(g_cvar)) Rule(id)
    else if( 
get_pcvar_num(g_cvar) && (get_user_flags(id) & ADMIN_KICK)) Rule(id)
}

public 
client_disconnect(idtype_spec[id] = false
public client_connect(idtype_spec[id] = false
public Rule(idset_task(20.0"PrintRule"id
7thSense is offline
xeqtrcs
Member
Join Date: Aug 2016
Old 09-01-2016 , 13:32   Re: SwichSpecTeam problem
Reply With Quote #5

why only admin? i wanna use command all player ? how to ?
xeqtrcs is offline
xeqtrcs
Member
Join Date: Aug 2016
Old 09-01-2016 , 13:40   Re: SwichSpecTeam problem
Reply With Quote #6

Quote:
Originally Posted by Napoleon_be View Post
My version of what you want. Untested though

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>

#define PLUGIN "Switch Spec"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new pCvarSpecCounts

new iTransfers[33]
new 
CsTeams:iOldTeam[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /spec""CmdTransfer")
    
    
pCvarSpecCounts register_cvar("amx_spectimes""10")
}

public 
CmdTransfer(id) {
    if(
is_user_admin(id)) {
        new 
limit get_pcvar_num(pCvarSpecCounts)
        
        
iOldTeam[id] = cs_get_user_team(id)
        
        if(
iTransfers[id] >= limit) {
            
ColorChat(idGREEN"[/spec]^1 You can't use this command no more than %i times!"limit)
            return 
PLUGIN_HANDLED
        
}
        
        switch(
iOldTeam[id]) {
            case 
CS_TEAM_TSwitchToSpec(id)
            case 
CS_TEAM_CTSwitchToSpec(id)
            case 
CS_TEAM_SPECTATORSwitchBack(id)
            case 
CS_TEAM_UNASSIGNEDColorChat(idGREEN"[/spec]^1 You must be assigned to use this command.")
        }
    }
    return 
PLUGIN_HANDLED
}

public 
SwitchToSpec(id) {
    
user_kill(id)
    
ColorChat(idGREEN"[/spec]^1 You joined spectator team.")
    
cs_set_user_team(idCS_TEAM_SPECTATOR)
    
    
iTransfers[id]++
}

public 
SwitchBack(id) {
    
user_kill(id)
    
ColorChat(idGREEN"[/spec]^1 You joined back to your old team.")
    
cs_set_user_team(idiOldTeam[id])

its not working.because 10 minutes then not join old team
xeqtrcs is offline
7thSense
Member
Join Date: Jul 2016
Old 09-01-2016 , 13:51   Re: SwichSpecTeam problem
Reply With Quote #7

please read ... register_cvar("amx_specmode", "0") // 0 - enable use to all, 1 - enable use only ADMINs
1 is for Admins only
0 is for all ...
7thSense is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-02-2016 , 03:57   Re: SwichSpecTeam problem
Reply With Quote #8

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>
#include <hamsandwich>

#define PLUGIN "Switch Spec"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new pCvarSpecCounts

new iTransfers[33]
new 
CsTeams:iOldTeam[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /spec""CmdTransfer")
    
    
pCvarSpecCounts register_cvar("amx_spectimes""10")
}

public 
CmdTransfer(id) {
    if(
is_user_admin(id)) {
        new 
limit get_pcvar_num(pCvarSpecCounts)
        
        
iOldTeam[id] = cs_get_user_team(id)
        
        if(
iTransfers[id] >= limit) {
            
ColorChat(idGREEN"[/spec]^1 You can't use this command no more than %i times!"limit)
            return 
PLUGIN_HANDLED
        
}
        
        switch(
iOldTeam[id]) {
            case 
CS_TEAM_TSwitchToSpec(id)
                case 
CS_TEAM_CTSwitchToSpec(id)
                case 
CS_TEAM_SPECTATORSwitchBack(id)
                case 
CS_TEAM_UNASSIGNEDColorChat(idGREEN"[/spec]^1 You must be assigned to use this command.")
            }
    }
    return 
PLUGIN_HANDLED
}

public 
SwitchToSpec(id) {
    
user_kill(id)
    
ColorChat(idGREEN"[/spec]^1 You joined spectator team.")
    
cs_set_user_team(idCS_TEAM_SPECTATOR)
    
    
iTransfers[id]++
}

public 
SwitchBack(id) {
    
ColorChat(idGREEN"[/spec]^1 You joined back to your old team.")
    
cs_set_user_team(idiOldTeam[id])
    
ExecuteHamB(Ham_CS_RoundRespawnid)

Fixed the respawn thingy.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
xeqtrcs
Member
Join Date: Aug 2016
Old 09-02-2016 , 05:00   Re: SwichSpecTeam problem
Reply With Quote #9

@7thSense

/spec command working its okay but
/back command problematic. Because round not finish player join game. Its a bug. For example im playing then im dead. Im write /spec then /back im again playing same round. How to fix it?
xeqtrcs is offline
7thSense
Member
Join Date: Jul 2016
Old 09-02-2016 , 05:24   Re: SwichSpecTeam problem
Reply With Quote #10

Quote:
Originally Posted by xeqtrcs View Post
@7thSense

/spec command working its okay but
/back command problematic. Because round not finish player join game. Its a bug. For example im playing then im dead. Im write /spec then /back im again playing same round. How to fix it?
try.
PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <cstrike> 
#include <fun> 
#include <colorchat> 
#include <hamsandwich>

#define PLUGIN "Spec Switch" 
#define VERSION "0.1.3" 
#define AUTHOR "many" 

new CsTeams:zTeam[33
new 
zDeath[33
new 
bool:type_spec[33] = false 
new g_cvar 

public plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR
    
/* Cvar */ 
    
g_cvar    register_cvar("amx_specmode",    "0")     // 0 - enable use to all, 1 - enable use only ADMINs 
    /* Client Commands */ 
    
register_clcmd("say /spec",         "cmdSpec"ADMIN_ALL"- go to spectator"
    
register_clcmd("say_team /spec",     "cmdSpec"ADMIN_ALL"- go to spectator"
    
register_clcmd("say /back",         "cmdBack"ADMIN_ALL"- go back to your team"
    
register_clcmd("say_team /back",     "cmdBack"ADMIN_ALL"- go back to your team"


public 
cmdSpec(id

    if(!
get_pcvar_num(g_cvar)) Spec(id
    else if( 
get_pcvar_num(g_cvar) && (get_user_flags(id) & ADMIN_KICK)) Spec(id
    else if( 
get_pcvar_num(g_cvar) && !(get_user_flags(id) & ADMIN_KICK)) PrintUserNotAdmin(id


public 
cmdBack(id

    if (
type_spec[id] && cs_get_user_team(id) == CS_TEAM_SPECTATOR && zTeam[id] != CS_TEAM_SPECTATOR Back(id
    else if( 
get_pcvar_num(g_cvar) && !(get_user_flags(id) & ADMIN_KICK) ) PrintUserNotAdmin(id


public 
Spec(id

    
zDeath[id] = cs_get_user_deaths(id
    if (
cs_get_user_team(id) == CS_TEAM_SPECTATOR
    return 
    else{ 
        
type_spec[id] = true 
        zTeam
[id] = cs_get_user_team(id
        
cs_set_user_team(idCS_TEAM_SPECTATOR
        
user_silentkill(id
        
ColorChat(idGREY,"^4[^3prafix^4]^3Type ^4/back ^3to return from ^4Spectator"
    } 
    return 


public 
Back(id

    
cs_set_user_team(idzTeam[id]) 
    
cs_set_user_deaths(idzDeath[id]) 
    
set_task(0.5,"FirstRespawn",id
    
set_task(0.8,"SecondRespawn",id
    
ExecuteHamB(Ham_CS_RoundRespawnid)


public 
FirstRespawn(id

    
cs_user_spawn(id


public 
SecondRespawn(id

    
cs_user_spawn(id
    if (
cs_get_user_team(id) == CS_TEAM_T){ 
        
give_item(id,"weapon_knife"
    } 
    if (
cs_get_user_team(id) == CS_TEAM_CT){ 
        
give_item(id,"weapon_knife"
    } 


PrintUserNotAdmin(id

    
ColorChat(idGREY,"^4[^3prefix^4]^3Only ^4Admins ^3can use ^4/spec, /back ^3command"


public 
PrintRule(id

    if ( 
is_user_connected(id) && !is_user_bot(id) && !is_user_hltv(id) ){ 
        
ColorChat(idGREY,"^4[^3prefix^4]^3 Type ^4/spec ^3if you want to go ^4Spectator"
        
ColorChat(idGREY,"^4[^3prefix^4]^3 Type ^4/back ^3to return from ^4Spectator"
    } 


public 
client_putinserver(id

    if(!
get_pcvar_num(g_cvar)) Rule(id
    else if( 
get_pcvar_num(g_cvar) && (get_user_flags(id) & ADMIN_KICK)) Rule(id


public 
client_disconnect(idtype_spec[id] = false 
public client_connect(idtype_spec[id] = false 
public Rule(idset_task(20.0"PrintRule"id
if dont work just use the @Napoleon_be plugin.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>
#include <hamsandwich>

#define PLUGIN "Switch Spec"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new pCvarSpecCounts

new iTransfers[33]
new 
CsTeams:iOldTeam[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /spec""CmdTransfer")
    
    
pCvarSpecCounts register_cvar("amx_spectimes""10")
}

public 
CmdTransfer(id) {
    if(
is_user_admin(id)) {
        new 
limit get_pcvar_num(pCvarSpecCounts)
        
        
iOldTeam[id] = cs_get_user_team(id)
        
        if(
iTransfers[id] >= limit) {
            
ColorChat(idGREEN"[/spec]^1 You can't use this command no more than %i times!"limit)
            return 
PLUGIN_HANDLED
        
}
        
        switch(
iOldTeam[id]) {
            case 
CS_TEAM_TSwitchToSpec(id)
                case 
CS_TEAM_CTSwitchToSpec(id)
                case 
CS_TEAM_SPECTATORSwitchBack(id)
                case 
CS_TEAM_UNASSIGNEDColorChat(idGREEN"[/spec]^1 You must be assigned to use this command.")
            }
    }
    return 
PLUGIN_HANDLED
}

public 
SwitchToSpec(id) {
    
user_kill(id)
    
ColorChat(idGREEN"[/spec]^1 You joined spectator team.")
    
cs_set_user_team(idCS_TEAM_SPECTATOR)
    
    
iTransfers[id]++
}

public 
SwitchBack(id) {
    
ColorChat(idGREEN"[/spec]^1 You joined back to your old team.")
    
cs_set_user_team(idiOldTeam[id])
    
ExecuteHamB(Ham_CS_RoundRespawnid)

i really dont have time now to fix my plugin if don't work.
7thSense is offline
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 09:49.


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