Is there a better way to do this? Sometimes it doesn't select a player.
What I'm trying to do is select a random human player at the start of each round to be the VIP. The way the server is set up, humans are on 1 team with bots on the other. Would this code cause any problems if there was only 1 human on the server?
PHP Code:
new g_iVIPid = 0;
new CsTeams:g_VIPteam;
public plugin_init()
{
register_event("HLTV", "NewRound", "a", "1=0", "2=0");
}
public NewRound()
{
new vPlayers[32], vPlayerNum, vName[32];
get_players(vPlayers, vPlayerNum, "ac");
g_BombPlanted = false;
if(vPlayerNum)
{
g_iVIPid = vPlayers[(vPlayerNum > 1) ? random(vPlayerNum) : 0]; //Set random human player to VIP
g_VIPteam = cs_get_user_team(g_iVIPid); //Get team VIP is on
get_user_name(g_iVIPid, vName, charsmax(vName));
ColorChat(0,RED, "[%s] ^4%s ^1is VIP this round. Stick together team!", PrefixName, vName);
}
}
__________________