hlmod.hu
https://hlmod.hu/

Glow,gyorsitohoz
https://hlmod.hu/viewtopic.php?f=9&t=4389
Oldal: 1 / 1

Szerző:  ChaspeR [2012.05.13. 16:08 ]
Hozzászólás témája:  Glow,gyorsitohoz

Kód:
/*================================================================================
   
   ----------------------------------------
   -*- [ZP] Extra Item: Speed Boost 1.2 -*-
   ----------------------------------------
   
   ~~~~~~~~~~~~~~~
   - Description -
   ~~~~~~~~~~~~~~~
   
   This item gives humans/zombies a short speed boost, configurable
   by cvars: zp_boost_amount and zp_boost_duration.
   
   ZP 4.3 Fix 5 or later required.
   
   ~~~~~~~~~~~~~
   - Changelog -
   ~~~~~~~~~~~~~
   
   * v1.0: (Jun 21, 2011)
      - First release
   
   * v1.1: (Jun 22, 2011)
      - Fixed speed not properly restored if player gets frozen after
         buying the speed boost (high zp_frost_duration settings)
   
   * v1.2: (Jul 02, 2011)
      - Changed speed setting method to be compatible with ZP 4.3 Fix5
   
================================================================================*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>

const TASK_SPEED_BOOST = 100
#define ID_SPEED_BOOST (taskid - TASK_SPEED_BOOST)

// Hack to be able to use Ham_Player_ResetMaxSpeed (by joaquimandrade)
new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame

new g_itemid_boost
new cvar_boost_amount
new cvar_boost_duration
new g_has_speed_boost[33]

public plugin_init()
{
   register_plugin("[ZP] Extra Item Speed Boost", "1.2", "MeRcyLeZZ")
   
   g_itemid_boost = zp_register_extra_item("Sebesseg gyorsito", 32, ZP_TEAM_HUMAN | ZP_TEAM_ZOMBIE)
   cvar_boost_amount = register_cvar("zp_boost_amount", "250.0")
   cvar_boost_duration = register_cvar("zp_boost_duration", "200.0")
   
   RegisterHam(Ham_Player_ResetMaxSpeed, "player", "fw_ResetMaxSpeed_Post", 1)
   RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
   register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}

public zp_extra_item_selected(player, itemid)
{
   if (itemid == g_itemid_boost)
   {
      // Player frozen (or CS freezetime)
      if (pev(player, pev_maxspeed) <= 1)
      {
         client_print(player, print_chat, "[ZP] You can't use this item when frozen.")
         return ZP_PLUGIN_HANDLED;
      }
      
      // Already using speed boost
      if (g_has_speed_boost[player])
      {
         client_print(player, print_chat, "[ZP] You already have the speed boost.")
         return ZP_PLUGIN_HANDLED;
      }
      
      // Enable speed boost
      g_has_speed_boost[player] = true
      client_print(player, print_chat, "[ZP] Gyorsasag aktivalva!!")
      
      // Set the restore speed task
      set_task(get_pcvar_float(cvar_boost_duration), "restore_maxspeed", player+TASK_SPEED_BOOST)
      
      // Update player's maxspeed
      ExecuteHamB(Ham_Player_ResetMaxSpeed, player)
   }
   return PLUGIN_CONTINUE;
}

public restore_maxspeed(taskid)
{
   // Disable speed boost
   g_has_speed_boost[ID_SPEED_BOOST] = false
   client_print(ID_SPEED_BOOST, print_chat, "[ZP] A sebesseg gyorsito LEJART !")
   
   // Update player's maxspeed
   ExecuteHamB(Ham_Player_ResetMaxSpeed, ID_SPEED_BOOST)
}

// Remove speed boost task when infected, humanized, killed, or disconnected
public zp_user_infected_pre(id, infector, nemesis)
{
   g_has_speed_boost[id] = false
   remove_task(id+TASK_SPEED_BOOST)
}
public zp_user_humanized_pre(id, survivor)
{
   g_has_speed_boost[id] = false
   remove_task(id+TASK_SPEED_BOOST)
}
public fw_PlayerKilled(victim)
{
   g_has_speed_boost[victim] = false
   remove_task(victim+TASK_SPEED_BOOST)
}
public client_disconnect(id)
{
   g_has_speed_boost[id] = false
   remove_task(id+TASK_SPEED_BOOST)
}

// Remove speed boost at round start
public event_round_start()
{
   new id
   for (id = 1; id <= get_maxplayers(); id++)
   {
      g_has_speed_boost[id] = false
      remove_task(id+TASK_SPEED_BOOST)
   }
}

public fw_ResetMaxSpeed_Post(id)
{
   if (!is_user_alive(id) || !g_has_speed_boost[id])
      return;
   
   // Apply speed boost
   new Float:current_maxspeed
   pev(id, pev_maxspeed, current_maxspeed)
   set_pev(id, pev_maxspeed, current_maxspeed + get_pcvar_float(cvar_boost_amount))
}


Ha megveszik , akkor kapjon egy glowot, de ne ilyen kicsit közepes méretben (Sárga legyen)

Köszi

Szerző:  oroszrulett [2012.05.15. 07:22 ]
Hozzászólás témája:  Re: Glow,gyorsitohoz

Kód:
  1. /*================================================================================

  2.    

  3.    ----------------------------------------

  4.    -*- [ZP] Extra Item: Speed Boost 1.2 -*-

  5.    ----------------------------------------

  6.    

  7.    ~~~~~~~~~~~~~~~

  8.    - Description -

  9.    ~~~~~~~~~~~~~~~

  10.    

  11.    This item gives humans/zombies a short speed boost, configurable

  12.    by cvars: zp_boost_amount and zp_boost_duration.

  13.    

  14.    ZP 4.3 Fix 5 or later required.

  15.    

  16.    ~~~~~~~~~~~~~

  17.    - Changelog -

  18.    ~~~~~~~~~~~~~

  19.    

  20.    * v1.0: (Jun 21, 2011)

  21.       - First release

  22.    

  23.    * v1.1: (Jun 22, 2011)

  24.       - Fixed speed not properly restored if player gets frozen after

  25.          buying the speed boost (high zp_frost_duration settings)

  26.    

  27.    * v1.2: (Jul 02, 2011)

  28.       - Changed speed setting method to be compatible with ZP 4.3 Fix5

  29.    

  30. ================================================================================*/

  31.  

  32. #include <amxmodx>

  33. #include <fakemeta>

  34. #include <hamsandwich>

  35. #include <zombieplague>

  36. #include <fun>

  37.  

  38. const TASK_SPEED_BOOST = 100

  39. #define ID_SPEED_BOOST (taskid - TASK_SPEED_BOOST)

  40.  

  41. // Hack to be able to use Ham_Player_ResetMaxSpeed (by joaquimandrade)

  42. new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame

  43.  

  44. new g_itemid_boost

  45. new cvar_boost_amount

  46. new cvar_boost_duration

  47. new g_has_speed_boost[33]

  48.  

  49. public plugin_init()

  50. {

  51.    register_plugin("[ZP] Extra Item Speed Boost", "1.2", "MeRcyLeZZ")

  52.    

  53.    g_itemid_boost = zp_register_extra_item("Sebesseg gyorsito", 32, ZP_TEAM_HUMAN | ZP_TEAM_ZOMBIE)

  54.    cvar_boost_amount = register_cvar("zp_boost_amount", "250.0")

  55.    cvar_boost_duration = register_cvar("zp_boost_duration", "200.0")

  56.    

  57.    RegisterHam(Ham_Player_ResetMaxSpeed, "player", "fw_ResetMaxSpeed_Post", 1)

  58.    RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")

  59.    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")

  60. }

  61.  

  62. public zp_extra_item_selected(player, itemid)

  63. {

  64.    if (itemid == g_itemid_boost)

  65.    {

  66.       // Player frozen (or CS freezetime)

  67.       if (pev(player, pev_maxspeed) <= 1)

  68.       {

  69.          client_print(player, print_chat, "[ZP] You can't use this item when frozen.")

  70.          return ZP_PLUGIN_HANDLED;

  71.       }

  72.      

  73.       // Already using speed boost

  74.       if (g_has_speed_boost[player])

  75.       {

  76.          client_print(player, print_chat, "[ZP] You already have the speed boost.")

  77.          return ZP_PLUGIN_HANDLED;

  78.       }

  79.      

  80.       // Enable speed boost

  81.       g_has_speed_boost[player] = true

  82.       client_print(player, print_chat, "[ZP] Gyorsasag aktivalva!!")

  83.       set_user_rendering(player,kRenderFxGlowShell,255,170,0,kRenderNormal,25)

  84.      

  85.       // Set the restore speed task

  86.       set_task(get_pcvar_float(cvar_boost_duration), "restore_maxspeed", player+TASK_SPEED_BOOST)

  87.      

  88.       // Update player's maxspeed

  89.       ExecuteHamB(Ham_Player_ResetMaxSpeed, player)

  90.    }

  91.    return PLUGIN_CONTINUE;

  92. }

  93.  

  94. public restore_maxspeed(taskid)

  95. {

  96.    // Disable speed boost

  97.    g_has_speed_boost[ID_SPEED_BOOST] = false

  98.    client_print(ID_SPEED_BOOST, print_chat, "[ZP] A sebesseg gyorsito LEJART !")

  99.    set_user_rendering(ID_SPEED_BOOST,kRenderFxGlowShell,0, 0, 0,kRenderNormal,25)

  100.    

  101.    

  102.    // Update player's maxspeed

  103.    ExecuteHamB(Ham_Player_ResetMaxSpeed, ID_SPEED_BOOST)

  104. }

  105.  

  106. // Remove speed boost task when infected, humanized, killed, or disconnected

  107. public zp_user_infected_pre(id, infector, nemesis)

  108. {

  109.    g_has_speed_boost[id] = false

  110.    remove_task(id+TASK_SPEED_BOOST)

  111. }

  112. public zp_user_humanized_pre(id, survivor)

  113. {

  114.    g_has_speed_boost[id] = false

  115.    remove_task(id+TASK_SPEED_BOOST)

  116. }

  117. public fw_PlayerKilled(victim)

  118. {

  119.    g_has_speed_boost[victim] = false

  120.    remove_task(victim+TASK_SPEED_BOOST)

  121. }

  122. public client_disconnect(id)

  123. {

  124.    g_has_speed_boost[id] = false

  125.    remove_task(id+TASK_SPEED_BOOST)

  126. }

  127.  

  128. // Remove speed boost at round start

  129. public event_round_start()

  130. {

  131.    new id

  132.    for (id = 1; id <= get_maxplayers(); id++)

  133.    {

  134.       g_has_speed_boost[id] = false

  135.       remove_task(id+TASK_SPEED_BOOST)

  136.    }

  137. }

  138.  

  139. public fw_ResetMaxSpeed_Post(id)

  140. {

  141.    if (!is_user_alive(id) || !g_has_speed_boost[id])

  142.       return;

  143.    

  144.    // Apply speed boost

  145.    new Float:current_maxspeed

  146.    pev(id, pev_maxspeed, current_maxspeed)

  147.    set_pev(id, pev_maxspeed, current_maxspeed + get_pcvar_float(cvar_boost_amount))

  148. }

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/