View Single Post
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 04-15-2012 , 17:24   Re: Pick random player of server
Reply With Quote #4

I tried but did not work, one player is randomly chosen and win the HE.

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

public OnPluginStart()
{
    
HookEvent("round_start"round_start);
}

public 
Action:round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    
GetRndClient();
}

GetRndClient()
{
    
decl iClients[MaxClients];
    new 
numClients;
    
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && !IsClientSourceTV(i))
        {
            
iClients[numClients++] = i;
        }
    }
    
    if (
numClients)
    {
        return 
iClients[GetURandomInt() % numClients];
    }
    else
    {
        return -
1// no clients? let's not divide by zero. :)
    
}

    
GivePlayerItem(numClients"weapon_hegrenade");

Thanks.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM
rodrigo286 is offline