/*******************************************************************************

  misc.inc v0.1

  Some misc stocks.

*******************************************************************************/

#if defined _misc_stocks_included
  #endinput
#endif
#define _misc_stocks_included

#include <amxmod>
#include <Vexd_Utilities>
#include <VexdUM_stock>

stock bool:check_player(id, const msg[])
{
  if((id < 1) || (id > get_maxplayers())) {
    report_error("%s: Player %d invalid", msg, id)
    return true
  }
  if(!is_user_connected(id)) {
    report_error("%s: Player %d not in-game", msg, id)
    return true
  }
  return false
}

stock bool:check_entity(ent, const msg[])
{
  if((ent < 1) || (ent > get_maxentities())) {
    report_error("%s: Entity %d out of range", msg, ent)
    return true
  }
  if(!is_entity(ent)) {
    report_error("%s: Entity %d invalid", msg, ent)
    return true
  }
  return false
}

/* Strips user's weapons. */
stock strip_user_weapons(id) 
{
  if(check_player(id, "strip_user_weapons")) return 0

  new stripper = create_entity("player_weaponstrip")
  DispatchSpawn(stripper)
  entity_use(stripper, id)
  remove_entity(stripper)

  return 1
}
