Raised This Month: $ Target: $400
 0% 

CREATE TIMER for plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
vegeta1241
AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
Old 10-02-2018 , 07:42   CREATE TIMER for plugin
Reply With Quote #1

Hello i have a timer for my script to choose a random ct but want i timer for swap all player in Terrorist.
If you can help me

Code:
#include <sourcemod> 
#include <cstrike> 
#include <sdktools> 

public void OnPluginStart()
{
    HookEvent("round_end", round_end);
}

public Action round_end(Handle event, const char[] name, bool dontbroadcast)
{
    ServerCommand("mp_autoteambalance 0");
    new ctone = GetRandomPlayer();
    CreateTimer(2.0, goct, ctone);
    for (new i = 1; i <= MaxClients; i++) 
    {
        ChangeClientTeam(i, CS_TEAM_T);
    }
} 

public Action goct(Handle timer, ctone)
{
    ChangeClientTeam(ctone, CS_TEAM_CT);
}

GetRandomPlayer() 
{ 
    new clients[MaxClients+1], clientCount; 
    for (new i = 1; i <= MaxClients; i++) 
        if (IsClientInGame(i) && GetClientTeam(CS_TEAM_T))
        clients[clientCount++] = i; 
    return (clientCount == 0) ? -1 : clients[GetRandomInt(0, clientCount-1)]; 
}
vegeta1241 is offline
 



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 22:10.


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