Your code is fine, can't throw a bound error on g_Knife[attacker] if g_Knife size is 33 and if you check is_user_connected(attacker) first.
I'm pretty sure the error is somewhere else or that you think you are using that code but you are wrong.
Since you can't give us the exact line it is extremly difficult to say.