Skocz do zawartości

Nowy szablon forum

mygo.pl

Stworzyliśmy dla Was nowy wygląd forum. Z pewnością znajdziesz rzeczy, które wg Ciebie mogą zostać zmienione - wspomnij o tym w specjalnym wątku.

Czytaj więcej

Jak założyć własną sieć

serwerów CS

Zastanawiasz się nad prowadzeniem własnej sieci serwerów? Przeczytaj podstawowe informacje, na które należy zwrócić uwagę, przy takim projekcie.

Czytaj więcej

Tworzymy spis sieci

dodaj swoją

Dodaj sieć do której należysz, pozwoli to na promocję i budowę ogólnopolskiej bazy sieci CS.

Czytaj więcej

Autojoin a blockchange team


Gość
 Udostępnij

Rekomendowane odpowiedzi

Witam

Na serwerze blokuje zmianę teamów graczowi aby nie mógł robić tego ręcznie poprzez plugin

#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1.0"

ConVar ATCEnable;

public Plugin myinfo =
{
    name = "Anti-Team Changer",
    author = "",
    description = "Blocks the \"jointeam\" command.",
    version = PLUGIN_VERSION,
    url = ""
}

public void OnPluginStart()
{
    AddCommandListener(CmdListener_Changeteam, "jointeam");
    AddCommandListener(CmdListener_Changeteam, "changeteam");
    ATCEnable = CreateConVar("atc_enable", "1", "Enable plugin?");
    CreateConVar("atc_version", PLUGIN_VERSION, "Plugin version");
    AutoExecConfig(true, "anti-team_changer");
}

public Action CmdListener_Changeteam(int client, const char[] command, int args)
{
    if(ATCEnable.BoolValue && client > 0 && IsClientInGame(client) && GetClientTeam(client) > 0 && !IsFakeClient(client) && !bIsAdminRoot(client))
        return Plugin_Handled;
    return Plugin_Handled; 
}

bool bIsAdminRoot(int client)
{
    if(CheckCommandAccess(client, "mycommand", ADMFLAG_ROOT))
        return true;
    return false;
}  

I problem pojawia się gdy do tego dorzucimy autojoin, w momencie gdy gracz już wrzuci do drużyny może on wtedy swobodnie zmieniać team pomimo gdy owy plugin powinnien to blokowac 

 

#include <sourcemod>
#include <cstrike>
#include <sdktools>

new Handle: Team

public Plugin:myinfo = {
    name = "Auto Join On Connect",
    author = "Divin!",
    description = "Based on players number with bug fixed",
    version = "1.0",
    url = "http://wtfcs.com/forum"
}

public OnPluginStart( ) {
    Team = CreateConVar( "sm_join_team", "1", "Do not edit this" )
    AddCommandListener(SelectTeam, "jointeam");
    HookEvent( "player_connect_full", Event_OnFullConnect, EventHookMode_Post )
}

public Event_OnFullConnect( Handle:event, const String:name[ ], bool:dontBroadcast ) {
    new client = GetClientOfUserId( GetEventInt( event, "userid" ) )
    
    if( client != 0 && IsClientInGame( client ) && !IsFakeClient( client ) ) {
        CreateTimer( 0.5, AssignTeam, client )
    }
}

public Action: AssignTeam( Handle: timer, any: client ) {
    if( IsClientInGame( client ) ) {
        int iCvar = GetConVarInt( Team )
        
        switch( iCvar ) {
            case 0 : {
                return Plugin_Handled
            }
            case 1 : {
                new iRed, iBlue;
                for(new i = 1; i <= MaxClients; i++)
                {
                    if(!IsClientInGame(i))
                        continue;

                    new iTeam = GetClientTeam(i);
                    if(iTeam == CS_TEAM_T)
                        iRed++;
                    else if(iTeam == CS_TEAM_CT)
                        iBlue++;
                }
                if( iRed > iBlue )
                {
                    ChangeClientTeam( client, 3 )
                }
                else
                if( iRed < iBlue )
                {
                    ChangeClientTeam( client, 2 )
                }
                else
                if( iRed == iBlue )
                {
                    ChangeClientTeam( client, 2 )
                }
                CS_RespawnPlayer(client);
                            
            }
            
            case 2 : {
                ChangeClientTeam( client, 2 )
            }
            
            case 3 : {
                ChangeClientTeam( client, 3 )
            }
        }
    }
    
    return Plugin_Continue
}

public Action:SelectTeam(client, const String:command[], args)
{
    if (client && args)
    {
        decl String:team[2];
        GetCmdArg(1, team, sizeof(team));
        switch (StringToInt(team))
        {
            case CS_TEAM_SPECTATOR: ChangeClientTeam(client, CS_TEAM_SPECTATOR);
            case CS_TEAM_T: {
                new iRed, iBlue;
                for(new i = 1; i <= MaxClients; i++)
                {
                    if(!IsClientInGame(i))
                        continue;

                    new iTeam = GetClientTeam(i);
                    if(iTeam == CS_TEAM_T)
                        iRed++;
                    else if(iTeam == CS_TEAM_CT)
                        iBlue++;
                }
                if( iRed < iBlue )
                {
                    ForcePlayerSuicide(client);
                    ChangeClientTeam( client, 2 )
                }
                else
                if( iRed == iBlue )
                {
                    ForcePlayerSuicide(client);
                    ChangeClientTeam( client, 2 )
                }
            }
            case CS_TEAM_CT: {
                new iRed, iBlue;
                for(new i = 1; i <= MaxClients; i++)
                {
                    if(!IsClientInGame(i))
                        continue;

                    new iTeam = GetClientTeam(i);
                    if(iTeam == CS_TEAM_T)
                        iRed++;
                    else if(iTeam == CS_TEAM_CT)
                        iBlue++;
                }
                if( iRed > iBlue )
                {
                    ForcePlayerSuicide(client);
                    ChangeClientTeam( client, 3 )
                }
                else
                if( iRed == iBlue )
                {
                    ForcePlayerSuicide(client);
                    ChangeClientTeam( client, 3 )
                }
            }
        }
    }
    return Plugin_Continue;
}  

 

Edytowane przez Gość
Odnośnik do komentarza
Udostępnij na innych stronach

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Posiadasz już konto? Zaloguj się poniżej.

Zaloguj się
 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
  • Podobna zawartość

×
×
  • Dodaj nową pozycję...