Approved Last human rewards

Gameplay Addons
Post Reply
User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 560
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 46 times
Age: 19
Contact:

Last human rewards

#1

Post by Jack GamePlay » 9 Months Ago

| Description:
  • This plugin gives some rewards controlled by cvars to the last human as a support to survive.
  • Rewards available:
    • Speed.
    • Multijump.
    • Fire nades.
    • Frost nades.

| Cvars:
  • Amount of extra speed (default: 100).

    Code: Select all

    g_pCvarExtraSpeed = register_cvar("ze_rewhm_extra_speed", "100")
  • Amount of extra fire nades (default: 2).

    Code: Select all

    g_pCvarExtraFireNade = register_cvar("ze_rewhm_extra_firenade", "2")
  • Amount of extra frost nades (default: 2).

    Code: Select all

    g_pCvarExtraFrostNade = register_cvar("ze_rewhm_extra_frostnade", "2")

| Defines:
  • Give multijump as a reward? (default: yes) (to not to give, add // before the whole line).

    Code: Select all

    #define GIVE_MULTIJUMP
  • Add name of item fire nade that you wrote in ze_register_item in the file of fire nade (I'm using the default name of it).

    Code: Select all

    #define FIRE_NADE "Fire Nade"
  • Add name of item frost nade that you wrote in ze_register_item in the file of frost nade (I'm using the default name of it).

    Code: Select all

    #define FROST_NADE "Frost Nade"

| Changelog:
  • Spoiler!
    Image [Current version.]
    • First stable release.

| Code:
    1. #define GIVE_MULTIJUMP
    2. #include <zombie_escape>
    3. #if defined GIVE_MULTIJUMP
    4.     #include <ze_multijump>
    5. #endif
    6.  
    7. #define FIRE_NADE "Fire Nade"
    8. #define FROST_NADE "Frost Nade"
    9. #define TASK 1100
    10.  
    11. new g_pCvarExtraSpeed, g_pCvarExtraFireNade, g_pCvarExtraFrostNade, g_pCvarHumanSpeed
    12. new g_iLastHumanIndex
    13.  
    14. public plugin_init()
    15. {
    16.     register_plugin("[ZE] Addons: Rewards for last human", "1.0", "Jack GamePlay")
    17.  
    18.     g_pCvarExtraSpeed = register_cvar("ze_rewhm_extra_speed", "100")
    19.     g_pCvarExtraFireNade = register_cvar("ze_rewhm_extra_firenade", "2")
    20.     g_pCvarExtraFrostNade = register_cvar("ze_rewhm_extra_frostnade", "2")
    21.     g_pCvarHumanSpeed = get_cvar_pointer("ze_human_speed_factor")
    22.  
    23.     set_task(0.1, "Check_Humans", TASK, _, _, "b")
    24. }
    25.  
    26. public Check_Humans(TaskID)
    27. {
    28.     if (ze_is_game_started() && (ze_get_humans_number() == 1))
    29.     {
    30.         for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
    31.         {
    32.             if (ze_is_user_zombie(id) || !is_user_alive(id))
    33.                 continue
    34.  
    35.             Give_Reward(id)
    36.             g_iLastHumanIndex = id
    37.             remove_task(TASK)
    38.             break
    39.         }
    40.     }
    41. }
    42.  
    43. public Give_Reward(id)
    44. {
    45.     ze_set_human_speed_factor(id, get_pcvar_num(g_pCvarHumanSpeed) + get_pcvar_num(g_pCvarExtraSpeed))
    46.  
    47.     #if defined GIVE_MULTIJUMP
    48.         ze_give_user_multijump(id)
    49.     #endif
    50.  
    51.     if (get_pcvar_num(g_pCvarExtraFireNade) > 0)
    52.     {
    53.         new index1, iFire = get_pcvar_num(g_pCvarExtraFireNade)
    54.         for (new index1 = 1; index1 <= iFire; index1++)
    55.         {
    56.             ze_force_buy_item(id, ze_get_item_id(FIRE_NADE), true)
    57.         }
    58.     }
    59.  
    60.     if (get_pcvar_num(g_pCvarExtraFrostNade) > 0)
    61.     {
    62.         new index2, iFrost = get_pcvar_num(g_pCvarExtraFrostNade)
    63.         for (index2 = 1; index2 <= iFrost; index2++)
    64.         {
    65.             ze_force_buy_item(id, ze_get_item_id(FROST_NADE), true)
    66.         }
    67.     }
    68.  
    69.     ze_colored_print(id, "!gYou are the last human. You got rewards.")
    70. }
    71.  
    72. public ze_user_humanized(g_iLastHumanIndex)
    73. {
    74.     ze_reset_human_speed(g_iLastHumanIndex)
    75. }
These users thanked the author Jack GamePlay for the post:
DarkZombie (9 Months Ago)
Not interested in CS/Pawn anymore.
Accepting web projects.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1793
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 89 times
Age: 21
Contact:

#2

Post by Raheem » 9 Months Ago

Fix speed:

  1. #define GIVE_MULTIJUMP
  2. #include <zombie_escape>
  3. #if defined GIVE_MULTIJUMP
  4.     #include <ze_multijump>
  5. #endif
  6.  
  7. #define FIRE_NADE "Fire Nade"
  8. #define FROST_NADE "Frost Nade"
  9. #define TASK 1100
  10.  
  11. new g_pCvarExtraSpeed, g_pCvarExtraFireNade, g_pCvarExtraFrostNade
  12.  
  13. new g_pCvarHumanSpeed
  14.  
  15. public plugin_init()
  16. {
  17.     register_plugin("[ZE] Addons: Rewards for last human", "1.0", "Jack GamePlay")
  18.  
  19.     g_pCvarExtraSpeed = register_cvar("ze_rewhm_extra_speed", "100")
  20.     g_pCvarExtraFireNade = register_cvar("ze_rewhm_extra_firenade", "2")
  21.     g_pCvarExtraFrostNade = register_cvar("ze_rewhm_extra_frostnade", "2")
  22.     g_pCvarHumanSpeed = get_cvar_pointer("ze_human_speed_factor")
  23.  
  24.     set_task(0.1, "Check_Humans", TASK, _, _, "b")
  25. }
  26.  
  27. public Check_Humans(TaskID)
  28. {
  29.     if (ze_is_game_started() && (ze_get_humans_number() == 1))
  30.     {
  31.         for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  32.         {
  33.             if (ze_is_user_zombie(id) || !is_user_alive(id))
  34.                 continue
  35.  
  36.             Give_Reward(id)
  37.             remove_task(TASK)
  38.             break
  39.         }
  40.     }
  41. }
  42.  
  43. public Give_Reward(id)
  44. {
  45.     ze_set_human_speed_factor(id, get_pcvar_num(g_pCvarHumanSpeed) + get_pcvar_num(g_pCvarExtraSpeed))
  46.  
  47.     #if defined GIVE_MULTIJUMP
  48.         ze_give_user_multijump(id)
  49.     #endif
  50.  
  51.     if (get_pcvar_num(g_pCvarExtraFireNade) > 0)
  52.     {
  53.         new index1, iFire = get_pcvar_num(g_pCvarExtraFireNade)
  54.         for (new index1 = 1; index1 <= iFire; index1++)
  55.         {
  56.             ze_force_buy_item(id, ze_get_item_id(FIRE_NADE), true)
  57.         }
  58.     }
  59.  
  60.     if (get_pcvar_num(g_pCvarExtraFrostNade) > 0)
  61.     {
  62.         new index2, iFrost = get_pcvar_num(g_pCvarExtraFrostNade)
  63.         for (index2 = 1; index2 <= iFrost; index2++)
  64.         {
  65.             ze_force_buy_item(id, ze_get_item_id(FROST_NADE), true)
  66.         }
  67.     }
  68.  
  69.     ze_colored_print(id, "!gYou are the last human. You got rewards.")
  70. }
You don't know? Learn and you will know.

User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 560
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 46 times
Age: 19
Contact:

#3

Post by Jack GamePlay » 9 Months Ago

Raheem wrote:
9 Months Ago
Fix speed:

What? You changed the native's syntax?!

[ Post made via Android ]
Not interested in CS/Pawn anymore.
Accepting web projects.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1793
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 89 times
Age: 21
Contact:

#4

Post by Raheem » 9 Months Ago

Setting speed factor, should add factor that default in our mod to your new factor :)

[ Post made via Nexus 7 ]
You don't know? Learn and you will know.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1793
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 89 times
Age: 21
Contact:

#5

Post by Raheem » 9 Months Ago

I forget, you also need to reset speed at user humanized: Or you can store the id of this player and at round end reset speed for him so you don't mess with other plugins if any other setting user speed.
You don't know? Learn and you will know.

User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 560
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 46 times
Age: 19
Contact:

#6

Post by Jack GamePlay » 9 Months Ago

Code updated.

[ Post made via Android ]
Not interested in CS/Pawn anymore.
Accepting web projects.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1793
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 89 times
Age: 21
Contact:

#7

Post by Raheem » 9 Months Ago

Updated from Andriod? HOW xd :lol:???
You don't know? Learn and you will know.

User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 560
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 46 times
Age: 19
Contact:

#8

Post by Jack GamePlay » 9 Months Ago

Raheem wrote:
9 Months Ago
Updated from Andriod? HOW xd :lol:???
Wrote it.

[ Post made via Android ]
Not interested in CS/Pawn anymore.
Accepting web projects.

Post Reply

Who is online

Users browsing this forum: Yandex [Bot] and 3 guests