View Single Post
ilyasa48
AlliedModders Donor
Join Date: Feb 2018
Location: de_mirage
Old 05-09-2019 , 08:37   Re: Kick Players When player with flag join
Reply With Quote #17

Quote:
Originally Posted by Bacardi View Post
Ok, nice to hear. You could try increase timer delay 0.1 to 0.6 if that helps.

Or maybe we need look to hide team menu, and perhaps use cs_switchteam...
Now I don't have time to look

*edit
Hey. in CSGO, there is event "jointeam_failed". I try re-code my sample

*edit edit
Hey, here different plugin versio of this.
- follow event "jointeam_failed"
- not look jointeam command.
PHP Code:
/*
Server event "jointeam_failed", Tick 44284:
- "userid" = "2"
- "reason" = "2"

Server event "jointeam_failed", Tick 44435:
- "userid" = "2"
- "reason" = "3"

Server event "jointeam_failed", Tick 44709:
- "userid" = "2"
- "reason" = "1"

*/



public void OnPluginStart()
{
    
HookEventEx("jointeam_failed"jointeam_failed);
}


public 
void jointeam_failed(Event event, const char[] namebool dontBroadcast)
{

    
int client GetClientOfUserId(event.GetInt("userid"));

    if(
client == || !IsClientInGame(client) || IsFakeClient(client) || GetClientTeam(client) > 1) return;


    
// reason:
    // 1 = Random team join - both team full;
    // 2 = Terrorist team join - team full;
    // 3 = Counter-Terrorist team join - team full;

    
if(event.GetInt("reason") != 1) return;

    if(!
CheckCommandAccess(client"vip"ADMFLAG_RESERVATION)) return;



    
int count;
    
int[] players = new int[MaxClients+1];

    for(
int i 1<= MaxClientsi++)
    {
        if(
client == || !IsClientInGame(i) || IsFakeClient(i) || GetClientTeam(i) < || IsClientInKickQueue(i)) continue;

        
players[count] = i;
        
count++;
        
    }

    
// no free slots and no humans. Do nothing. No spawnpoints on map?
    
if(count == 0) return;

    
// get random target
    
int target players[GetRandomInt(0count-1)];

    
// Is target in admin cache
    
AdminId target_adminid GetUserAdmin(target);

    if(
target_adminid != INVALID_ADMIN_ID)
    {

        
AdminId client_adminid GetUserAdmin(client);

        
// You can't target this admin!
        
if(!CanAdminTarget(client_adminidtarget_adminid))
        {
            
PrintHintText(client"[SM] Couldn't kick %N\nPlease, try jointeam random again."target);
            return;
        }

        
// You can't target this vip!
        // Use this code if you not want vip to kick another vip

        //if(CheckCommandAccess(target, "vip", ADMFLAG_RESERVATION))
        //{
        //    PrintHintText(client, "<font color='#FF6A00'>[SM]</font> Couldn't kick %N\nPlease, try jointeam random again.", target);
        //    return;
        //}
    
}


    
LogAction(clienttarget"Jointeam kick - Player %L kicked from server to make room for player %L"targetclient);
    
KickClient(target"[SM] You have kicked from server to make room for VIP/admins. Sorry");

    
CreateTimer(0.6delayGetClientUserId(client));



}

public 
Action delay(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);

    if(
client != && IsClientInGame(client) && GetClientTeam(client) < 2FakeClientCommandEx(client"jointeam 0 1");

    return 
Plugin_Continue;

its not work, could you fix this?

thanks before
ilyasa48 is offline