Quote:
Originally Posted by Bugsy
PHP Code:
new iPlayers[ 32 ] , iNum , iRandom; get_players( iPlayers , iNum );
if ( iNum ) { iRandom = iPlayers [ random( iNum ) ]; }
|
Works ty, also quick question, i made this if no player is connected, dunno if its right though ( it works, i tested )
HTML Code:
public ChooseHero()
{
new iPlayers[ 32 ] , iNum , iRandom;
get_players( iPlayers , iNum );
if ( iNum ) {
iRandom = iPlayers [ random( iNum ) ];
}
else if ( !iNum ) {
return PLUGIN_HANDLED;
}
set_user_armor(iRandom, get_user_armor(iRandom) + 150);
set_user_health(iRandom, get_user_health(iRandom) + 150);
give_item(iRandom, "weapon_hegrenade");
give_item(iRandom, "weapon_flashbang");
new szName[32];
get_user_name(iRandom, szName, charsmax(szName));
ColorChat(0, GREEN, "^x01[^x04SPK ZM^x01]^x04 %s ^x03was chosen to be the ^x04Hero ^x03of the round! They have got ^x04+150HP+150AP+MULTIJUMPS", szName);
}
edit : if i want to skip bots and dead players how should i do it?
edit 2 : i made a check to see if user is bot and if is dead but what should i return, or what should i do to choose another player?
HTML Code:
public ChooseHero()
{
new iPlayers[ 32 ] , iNum , iRandom;
get_players( iPlayers , iNum );
if ( iNum ) {
iRandom = iPlayers [ random( iNum ) ];
}
else if ( !iNum ) {
return PLUGIN_HANDLED;
}
else if ( !is_user_alive (iRandom) || is_user_bot( iRandom )) {
return;
}
set_user_armor(iRandom, get_user_armor(iRandom) + 150);
set_user_health(iRandom, get_user_health(iRandom) + 150);
give_item(iRandom, "weapon_hegrenade");
give_item(iRandom, "weapon_flashbang");
new szName[32];
get_user_name(iRandom, szName, charsmax(szName));
ColorChat(0, GREEN, "^x01[^x04SPK ZM^x01]^x04 %s ^x03was chosen to be the ^x04Hero ^x03of the round! They have got ^x04+150HP+150AP+MULTIJUMPS", szName);
}