Speed boost for humans only

Coding Help/Re-API Supported
Post Reply
Mystic Viper
Senior Member
Senior Member
Romania
Posts: 106
Joined: 1 Year Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

Speed boost for humans only

#1

Post by Mystic Viper » 6 Months 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
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#2

Post by Raheem » 6 Months 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. }
You don't know? Learn and you will know.

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 633
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 19
Contact:

#3

Post by Spir0x » 6 Months Ago

Bro is this plugin will be appeared in Extra-Items shop ? or only with /sb in chat.
I trynna make money, not friends.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 216
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#4

Post by sPe3doN » 6 Months Ago

Spir0x wrote:
6 Months 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

[ Post made via Android ]

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 633
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 19
Contact:

#5

Post by Spir0x » 5 Months Ago

Lmao what's cs_weap_models_api ? i said ze_speedbost.
I trynna make money, not friends.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 216
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#6

Post by sPe3doN » 5 Months Ago

Spir0x wrote:
5 Months 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

[ Post made via Android ]

User avatar
Muhammet20
Veteran Member
Veteran Member
Turkey
Posts: 408
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 15
Contact:

#7

Post by Muhammet20 » 5 Months Ago

sPe3doN wrote:
5 Months Ago
Spir0x wrote:
5 Months 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
[Learning HTML coding language]
[Learning Unreal Engine 4]
[Learning Adobe programs]

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest