Speed boost for humans only

Coding Help/Re-API Supported
Post Reply
Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

Speed boost for humans only

#1

Post by Templaso » 4 years ago

  1. #include <zombie_escape>
  2.  
  3. // Trail effect configs
  4. #define TRAIL_LIFE  2   // Life
  5. #define TRAIL_WIDTH 10  // Width
  6. #define TRAIL_RED   90  // Red color
  7. #define TRAIL_GREEN 200 // Green color
  8. #define TRAIL_BLUE  90  // Blue color
  9. #define TRAIL_ALPHA 220 // Alpha
  10.  
  11. new g_pCvarSpeedAmount, g_pCvarBoostTime, g_pCvarSpeedBoostDelay
  12. new bool:g_bCanUseSB[33], g_iCoolDown_Time[33]
  13. new g_iSpeedTrail
  14.  
  15. new const g_iSpeedSound[] = "zombie_escape/sprint.wav"
  16.  
  17. public plugin_precache()
  18. {
  19.     precache_sound(g_iSpeedSound)
  20.     g_iSpeedTrail = precache_model("sprites/smoke.spr")
  21. }
  22.  
  23. public plugin_init()
  24. {
  25.     register_plugin("[ZE] Addons: Speed Boost", "1.0", "Jack GamePlay")
  26.  
  27.     register_clcmd("say /sb", "SpeedBoost")
  28.  
  29.     g_pCvarBoostTime = register_cvar("ze_boost_time", "3.0")
  30.     g_pCvarSpeedAmount = register_cvar("ze_speed_amount", "450")
  31.     g_pCvarSpeedBoostDelay = register_cvar("ze_speedboost_delay", "10.0")
  32. }
  33.  
  34. public client_putinserver(id)
  35. {
  36.     g_bCanUseSB[id] = false
  37. }
  38.  
  39. public client_disconnected(id)
  40. {
  41.     g_bCanUseSB[id] = false
  42. }
  43.  
  44. public ze_user_infected(id)
  45. {
  46.     if (!is_user_alive(id))
  47.         return
  48.  
  49.     g_bCanUseSB[id] = true
  50. }
  51.  
  52. public ze_user_humanized(id)
  53. {
  54.     if (!is_user_alive(id))
  55.         return
  56.  
  57.     g_bCanUseSB[id] = false
  58. }
  59.  
  60. public SpeedBoost(id)
  61. {
  62.     if (!is_user_alive(id))
  63.         return PLUGIN_CONTINUE
  64.  
  65.     if (!ze_is_user_zombie(id))
  66.     {
  67.         ze_colored_print(id, "!tThis option is for !gzombies !tonly!y.")
  68.         return PLUGIN_HANDLED
  69.     }
  70.  
  71.     if (g_bCanUseSB[id])
  72.     {
  73.         g_bCanUseSB[id] = false
  74.         ze_set_zombie_speed(id, get_pcvar_num(g_pCvarSpeedAmount))
  75.         ze_colored_print(id, "!tYou got !y[!g%i!y] !tspeed for !y[!g%i!y] !tsec!y.", get_pcvar_num(g_pCvarSpeedAmount), floatround(get_pcvar_float(g_pCvarBoostTime)))
  76.  
  77.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  78.         write_byte(TE_BEAMFOLLOW)
  79.         write_short(id)
  80.         write_short(g_iSpeedTrail)
  81.         write_byte(TRAIL_LIFE)
  82.         write_byte(TRAIL_WIDTH)
  83.         write_byte(TRAIL_RED)
  84.         write_byte(TRAIL_GREEN)
  85.         write_byte(TRAIL_BLUE)
  86.         write_byte(TRAIL_ALPHA)
  87.         message_end()
  88.  
  89.         emit_sound(id, CHAN_STREAM, g_iSpeedSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  90.         set_task(get_pcvar_float(g_pCvarBoostTime), "Remove_Boost", id)
  91.     }
  92.  
  93.     return PLUGIN_CONTINUE
  94. }
  95.  
  96. public Remove_Boost(id)
  97. {
  98.     if (!is_user_alive(id) || !ze_is_user_zombie(id))
  99.         return
  100.  
  101.     g_bCanUseSB[id] = false
  102.     g_iCoolDown_Time[id] = floatround(get_pcvar_float(g_pCvarSpeedBoostDelay))
  103.     ze_reset_zombie_speed(id)
  104.     ze_colored_print(id, "!gSpeed boost has ended!y.")
  105.     set_task(1.0, "ShowHUD", id, _, _, "a", g_iCoolDown_Time[id])
  106.     set_task(get_pcvar_float(g_pCvarSpeedBoostDelay), "Allow_Again", id)
  107. }
  108.  
  109. public ShowHUD(id)
  110. {
  111.     if (!is_user_alive(id))
  112.         return
  113.  
  114.     if (!g_bCanUseSB[id])
  115.     {
  116.         g_iCoolDown_Time[id] = g_iCoolDown_Time[id] - 1
  117.         set_hudmessage(200, 200, 200, 0.75, 0.92, 0, 1.0, 1.1, 0.0, 0.0, -1)
  118.         show_hudmessage(id, "Sprint cooldown: %i", g_iCoolDown_Time[id])
  119.     }
  120. }
  121.  
  122. public Allow_Again(id)
  123. {
  124.     if (!is_user_alive(id) || !ze_is_user_zombie(id))
  125.         return
  126.  
  127.     g_bCanUseSB[id] = true
  128.     ze_colored_print(id, "!gSpeed boost can be used!y.")
  129. }
  130. }

This plugin gaves for zombies a little speed for few seconds.
I want it to be made for humans and the zombies can't use it and can be used one per round.

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 4 years ago

  1. #include <zombie_escape>
  2.  
  3. // Trail effect configs
  4. #define TRAIL_LIFE  2   // Life
  5. #define TRAIL_WIDTH 10  // Width
  6. #define TRAIL_RED   90  // Red color
  7. #define TRAIL_GREEN 200 // Green color
  8. #define TRAIL_BLUE  90  // Blue color
  9. #define TRAIL_ALPHA 220 // Alpha
  10.  
  11. new g_pCvarSpeedAmount, g_pCvarBoostTime, g_pCvarSpeedBoostDelay
  12. new bool:g_bCanUseSB[33], g_iCoolDown_Time[33]
  13. new g_iSpeedTrail
  14.  
  15. new const g_iSpeedSound[] = "zombie_escape/sprint.wav"
  16.  
  17. public plugin_precache()
  18. {
  19.     precache_sound(g_iSpeedSound)
  20.     g_iSpeedTrail = precache_model("sprites/smoke.spr")
  21. }
  22.  
  23. public plugin_init()
  24. {
  25.     register_plugin("[ZE] Addons: Speed Boost", "1.0", "Jack GamePlay")
  26.  
  27.     register_clcmd("say /sb", "SpeedBoost")
  28.  
  29.     g_pCvarBoostTime = register_cvar("ze_boost_time", "3.0")
  30.     g_pCvarSpeedAmount = register_cvar("ze_speed_amount", "450")
  31.     g_pCvarSpeedBoostDelay = register_cvar("ze_speedboost_delay", "10.0")
  32. }
  33.  
  34. public client_putinserver(id)
  35. {
  36.     g_bCanUseSB[id] = false
  37. }
  38.  
  39. public client_disconnected(id)
  40. {
  41.     g_bCanUseSB[id] = false
  42. }
  43.  
  44. public ze_user_infected(id)
  45. {
  46.     if (!is_user_alive(id))
  47.         return
  48.  
  49.     g_bCanUseSB[id] = true
  50. }
  51.  
  52. public ze_user_humanized(id)
  53. {
  54.     if (!is_user_alive(id))
  55.         return
  56.  
  57.     g_bCanUseSB[id] = false
  58. }
  59.  
  60. public SpeedBoost(id)
  61. {
  62.     if (!is_user_alive(id))
  63.         return PLUGIN_CONTINUE
  64.  
  65.     if (ze_is_user_zombie(id))
  66.     {
  67.         ze_colored_print(id, "!tThis option is for !gHumans !tonly!y.")
  68.         return PLUGIN_HANDLED
  69.     }
  70.  
  71.     if (g_bCanUseSB[id])
  72.     {
  73.         g_bCanUseSB[id] = false
  74.         ze_set_zombie_speed(id, get_pcvar_num(g_pCvarSpeedAmount))
  75.         ze_colored_print(id, "!tYou got !y[!g%i!y] !tspeed for !y[!g%i!y] !tsec!y.", get_pcvar_num(g_pCvarSpeedAmount), floatround(get_pcvar_float(g_pCvarBoostTime)))
  76.  
  77.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  78.         write_byte(TE_BEAMFOLLOW)
  79.         write_short(id)
  80.         write_short(g_iSpeedTrail)
  81.         write_byte(TRAIL_LIFE)
  82.         write_byte(TRAIL_WIDTH)
  83.         write_byte(TRAIL_RED)
  84.         write_byte(TRAIL_GREEN)
  85.         write_byte(TRAIL_BLUE)
  86.         write_byte(TRAIL_ALPHA)
  87.         message_end()
  88.  
  89.         emit_sound(id, CHAN_STREAM, g_iSpeedSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  90.         set_task(get_pcvar_float(g_pCvarBoostTime), "Remove_Boost", id)
  91.     }
  92.  
  93.     return PLUGIN_CONTINUE
  94. }
  95.  
  96. public Remove_Boost(id)
  97. {
  98.     if (!is_user_alive(id) || ze_is_user_zombie(id))
  99.         return
  100.  
  101.     g_bCanUseSB[id] = false
  102.     g_iCoolDown_Time[id] = floatround(get_pcvar_float(g_pCvarSpeedBoostDelay))
  103.     ze_reset_zombie_speed(id)
  104.     ze_colored_print(id, "!gSpeed boost has ended!y.")
  105.     set_task(1.0, "ShowHUD", id, _, _, "a", g_iCoolDown_Time[id])
  106.     set_task(get_pcvar_float(g_pCvarSpeedBoostDelay), "Allow_Again", id)
  107. }
  108.  
  109. public ShowHUD(id)
  110. {
  111.     if (!is_user_alive(id))
  112.         return
  113.  
  114.     if (!g_bCanUseSB[id])
  115.     {
  116.         g_iCoolDown_Time[id] = g_iCoolDown_Time[id] - 1
  117.         set_hudmessage(200, 200, 200, 0.75, 0.92, 0, 1.0, 1.1, 0.0, 0.0, -1)
  118.         show_hudmessage(id, "Sprint cooldown: %i", g_iCoolDown_Time[id])
  119.     }
  120. }
  121.  
  122. public Allow_Again(id)
  123. {
  124.     if (!is_user_alive(id) || ze_is_user_zombie(id))
  125.         return
  126.  
  127.     g_bCanUseSB[id] = true
  128.     ze_colored_print(id, "!gSpeed boost can be used!y.")
  129. }
He who fails to plan is planning to fail

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#3

Post by Spir0x » 4 years ago

Bro is this plugin will be appeared in Extra-Items shop ? or only with /sb in chat.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#4

Post by sPe3doN » 4 years ago

Spir0x wrote: 4 years ago Bro is this plugin will be appeared in Extra-Items shop ? or only with /sb in chat.
ididn't test it Try :

Code: Select all

#include <zombie_escape>
 
// Trail effect configs
#define TRAIL_LIFE  2   // Life
#define TRAIL_WIDTH 10  // Width
#define TRAIL_RED   90  // Red color
#define TRAIL_GREEN 200 // Green color
#define TRAIL_BLUE  90  // Blue color 
#define TRAIL_ALPHA 220 // Alpha
 
new g_pCvarSpeedAmount, g_pCvarBoostTime, g_pCvarSpeedBoostDelay
new bool:g_bCanUseSB[33], g_iCoolDown_Time[33], g_iLimit[33], cvar_limit
new g_iItemID, g_iSpeedTrail
 
new const g_iSpeedSound[] = "zombie_escape/sprint.wav"
 
public plugin_precache()
{
    precache_sound(g_iSpeedSound)
    g_iSpeedTrail = precache_model("sprites/smoke.spr")
}
 
public plugin_init()
{
    register_plugin("[ZE] Addons: Speed Boost", "1.0", "Jack GamePlay")
    g_iItemID = ze_register_item("Speed boost", 20, 0)
 
    register_clcmd("say /sb", "buy_SpeedBoost")
 
    g_pCvarBoostTime = register_cvar("ze_boost_time", "3.0")
    g_pCvarSpeedAmount = register_cvar("ze_speed_amount", "450")
    g_pCvarSpeedBoostDelay = register_cvar("ze_speedboost_delay", "10.0")
}
 
public client_putinserver(id)
{
    g_bCanUseSB[id] = false
}
 
public client_disconnected(id)
{
    g_bCanUseSB[id] = false
}
 
public ze_user_infected(id)
{
    if (!is_user_alive(id))
        return
 
    g_bCanUseSB[id] = true
}
 
public ze_user_humanized(id)
{
    if (!is_user_alive(id))
        return
 
    g_bCanUseSB[id] = false
}

// Buy throught extra items menu
public  ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_iItemID)
        return ZE_ITEM_AVAILABLE
   
    // Available for Zombies only, So don't show it for Humans
    if (!ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW  
   
    // If he bought it more than 3 so return that it's not Available
    if (g_iLimit[id] >= get_pcvar_num(cvar_limit))
        return ZE_ITEM_UNAVAILABLE
   
    return ZE_ITEM_AVAILABLE
} 
 
public  ze_select_item_post(id, itemid) 
{
    // This is not our item, Block it here and don't execute the blew code
    if (itemid != g_iItemID)
        return
	  
    buy_SpeedBoost(id) 
    g_iLimit[id]++ // Mean g_iLimit[id] = g_iLimit[id] + 1
}     
 
public buy_SpeedBoost(id)
{
    if (!is_user_alive(id))
        return PLUGIN_CONTINUE
 
    if (ze_is_user_zombie(id))
    {
        ze_colored_print(id, "!tThis option is for !gHumans !tonly!y.")
        return PLUGIN_HANDLED
    }
    if (!g_bCanUseSB[id])
    {
        g_bCanUseSB[id] = false
        ze_set_zombie_speed(id, get_pcvar_num(g_pCvarSpeedAmount))
        ze_colored_print(id, "!tYou got !y[!g%i!y] !tspeed for !y[!g%i!y] !tsec!y.", get_pcvar_num(g_pCvarSpeedAmount), floatround(get_pcvar_float(g_pCvarBoostTime)))
 
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(TE_BEAMFOLLOW)
        write_short(id)
        write_short(g_iSpeedTrail)
        write_byte(TRAIL_LIFE)
        write_byte(TRAIL_WIDTH)
        write_byte(TRAIL_RED)
        write_byte(TRAIL_GREEN)
        write_byte(TRAIL_BLUE)
        write_byte(TRAIL_ALPHA)
        message_end()
 
        emit_sound(id, CHAN_STREAM, g_iSpeedSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
        set_task(get_pcvar_float(g_pCvarBoostTime), "Remove_Boost", id)
    }
 
    return PLUGIN_CONTINUE
}
 
public Remove_Boost(id)
{
    if (!is_user_alive(id) || ze_is_user_zombie(id))
        return
 
    g_bCanUseSB[id] = false
    g_iCoolDown_Time[id] = floatround(get_pcvar_float(g_pCvarSpeedBoostDelay))
    ze_reset_zombie_speed(id)
    ze_colored_print(id, "!gSpeed boost has ended!y.")
    set_task(1.0, "ShowHUD", id, _, _, "a", g_iCoolDown_Time[id])
    set_task(get_pcvar_float(g_pCvarSpeedBoostDelay), "Allow_Again", id)
}
 
public ShowHUD(id)
{
    if (!is_user_alive(id))
        return
 
    if (!g_bCanUseSB[id])
    {
        g_iCoolDown_Time[id] = g_iCoolDown_Time[id] - 1
        set_hudmessage(200, 200, 200, 0.75, 0.92, 0, 1.0, 1.1, 0.0, 0.0, -1)
        show_hudmessage(id, "Sprint cooldown: %i", g_iCoolDown_Time[id])
    }
}
 
public Allow_Again(id)
{
    if (!is_user_alive(id) || ze_is_user_zombie(id))
        return
 
    g_bCanUseSB[id] = true
    ze_colored_print(id, "!gSpeed boost can be used!y.")
}
Capture.PNG
Image

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#5

Post by Spir0x » 4 years ago

Lmao what's cs_weap_models_api ? i said ze_speedbost.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#6

Post by sPe3doN » 4 years ago

Spir0x wrote: 4 years ago Lmao what's cs_weap_models_api ? i said ze_speedbost.
Lol juste try the code dont care about the pic cuz i replaced speed boost code on cs_weap_models_api file XD
Image

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#7

Post by Muhammet20 » 4 years ago

sPe3doN wrote: 4 years ago
Spir0x wrote: 4 years ago Lmao what's cs_weap_models_api ? i said ze_speedbost.
Lol juste try the code dont care about the pic cuz i replaced speed boost code on cs_weap_models_api file XD
XD Man , Lol

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 8 guests