Quote:
Originally Posted by padilha007
PHP Code:
#include <amxmodx> #include <fakemeta> public plugin_init() { register_plugin("Random Player", "0.1", "padilha007") register_logevent("random_player", 2, "1=Round_Start") } public random_player() { new players[32], totalplayers, randplayer; get_players(players, totalplayers) if (!randplayer) randplayer = random_num(1, totalplayers) if(!is_user_connected(randplayer) || !is_user_alive(randplayer)) { set_task(0.1, "random_player") return PLUGIN_HANDLED } // You stuff with randplayer // index = randplayer }
|
Quote:
Originally Posted by Exolent[jNr]
padilha's way is only good if you want 1 player.
If you want random players, see the tutorial that arkshine gave.
|
Good? No it isn't. It's not efficient and can take even 3 secs. Also the connected check isn't needed. And it's getting maxplayers many times even it isn't needed.
PHP Code:
new players[32], totalplayers, randplayer;
get_players(players, totalplayers, "a");
randplayer = random_num(1, totalplayers);
//player index is randplayer