I was just messing around and I thought of writing a plugin that would move a player to spectator if maybe they were afk and didn't want to kick them. I was wondering if you anyone might have some suggestions to improve my script. I it works fine on my server (linux fc6) but any thoughts would be great.
Code:
// Plugin for moving a player to spectator.
#include <amxmodx>
#include <amxmisc>
#include <dodfun>
#define PLUGIN "mv_spec"
#define VERSION "1.0"
#define AUTHOR "Fysiks"
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR)
register_concmd("admin_spec", "cmdMvSpec", ADMIN_KICK, "<player> - Moves player to spectator.")
}
public cmdMvSpec(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg[32]
read_argv(1, arg, 31)
new player = cmd_target(id, arg, 2)
if (!player)
return PLUGIN_HANDLED
new authid[32], name[32], userid
get_user_authid(player, authid, 31)
get_user_name(player, name, 31)
userid = get_user_userid(player)
new teamname[12]
get_user_team(player, teamname, 11)
if (is_user_bot(player))
{
console_print(id, "Kicking a bot is BAD, Action denied.")
return PLUGIN_HANDLED
}
if (teamname[0])
{
dod_set_user_team(player, 3, 1)
return PLUGIN_HANDLED
} else {
console_print(id, "No such player.")
return PLUGIN_HANDLED
}
}