Approved Last human rewards

Plug-ins compatibility with Zombie Escape 1.x only!


Post Reply
User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

Last human rewards

#1

Post by Night Fury » 5 years 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. }
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

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

#2

Post by Raheem » 5 years 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. }
He who fails to plan is planning to fail

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#3

Post by Night Fury » 5 years ago

Raheem wrote: 5 years ago Fix speed:

What? You changed the native's syntax?!
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

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

#4

Post by Raheem » 5 years ago

Setting speed factor, should add factor that default in our mod to your new factor :)
He who fails to plan is planning to fail

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

#5

Post by Raheem » 5 years 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.
He who fails to plan is planning to fail

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#6

Post by Night Fury » 5 years ago

Code updated.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

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

#7

Post by Raheem » 5 years ago

Updated from Andriod? HOW xd :lol:???
He who fails to plan is planning to fail

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#8

Post by Night Fury » 5 years ago

Raheem wrote: 5 years ago Updated from Andriod? HOW xd :lol:???
Wrote it.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
Crimson
Member
Member
Algeria
Posts: 7
Joined: 5 years ago
Contact:

#9

Post by Crimson » 3 years ago

dude next time put the inc files please :p the plugin will not work without inc file...

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 0 guests