Hello all. I found bug but i can't understand how to fix it. This plugin allows to enter spectate without killing and changing team. But if i kill myself and then try to go to the spectator and leave, there will be a bug. How can I fix it?
PHP Code:
#include <amxmodx>
#include <engine>
#include <fun>
public plugin_init() {
register_plugin("Plugin", "1.0", "AUTHOR")
register_clcmd("chooseteam", "spectate" );
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET );
}
public spectate(id)
{
if (is_user_alive(id)) { // enter to spectate
strip_user_weapons(id);
entity_set_int(id,EV_INT_movetype,MOVETYPE_NOCLIP)
entity_set_int(id,EV_INT_deadflag,DEAD_DEAD)
} else { // exit from spectate
spawn(id)
give_item(id, "weapon_knife")
give_item(id, "weapon_usp")
}
return PLUGIN_HANDLED;
}