#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#include <fakemeta>
#include <amxmisc>
 
#define PLUGIN "[ZP] Extra Item : Respawn"
#define VERSION "1.4"
#define AUTHOR "The_Thing\Maslyak"
 
static const plugin[] = "Ujraéledés";
new g_respawn_cost;
new thinkobj;
 
public plugin_init() 
{
   register_plugin(PLUGIN, VERSION, AUTHOR)
 
   g_respawn_cost = register_cvar("zp_respawn_cost", "10")
 
   register_clcmd("say /ujra", "buy_respawn")
   register_clcmd("say /respawn", "buy_respawn")
   register_clcmd("say /ujraeledes", "buy_respawn")
   thinkobj = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
   if ( pev_valid(thinkobj) )
   {
      set_pev(thinkobj, pev_classname, "advertisement_loop");
      set_pev(thinkobj, pev_nextthink, get_gametime() + 260.0);
      register_forward(FM_Think, "fourmin_think");
   }
}
 
public fourmin_think(ent)
{
    if ( ent != thinkobj )
    return FMRES_IGNORED;
 
    client_print(0, print_chat, "[%s] /ujra parancsal ! 10 LCS-be keről !", plugin);
    set_pev(ent, pev_nextthink, get_gametime() + 240.0);
 
    return FMRES_HANDLED;
}
 
public buy_respawn(id)
{
   if ( is_user_alive(id) )
   {
      client_print(id, print_chat, "[ZP] Te nem vagy halott  !! Ezt csak a halottak használhatják !", get_pcvar_num(g_respawn_cost))
      return PLUGIN_HANDLED
   }
   new money = zp_get_user_ammo_packs(id)
 
   if ( money < get_pcvar_num(g_respawn_cost))
   {
      client_print(id, print_chat, "[ZP] Nincs elég LCS-d hogy megvehesd ezt !", get_pcvar_num(g_respawn_cost))
      return PLUGIN_HANDLED
   }
 
   zp_set_user_ammo_packs(id, money - get_pcvar_num(g_respawn_cost))
 
   respawn_player(id)
   client_print(id, print_chat, "[ZP] Sikeresen újra éledtél ! 10 LCS levonva !")
 
   return PLUGIN_HANDLED
}
 
public respawn_player(id)
{
   if(zp_is_survivor_round())
   {
      zp_respawn_user(id, ZP_TEAM_ZOMBIE)
   }
   else
   {
      zp_respawn_user(id, ZP_TEAM_HUMAN)
   }   
}