Page 1 of 3

Zombie classes

Posted: 25 Jul 2018, 20:57
by Night Fury
|Description:
  • This plugin allows you to zombie classes with different speed, health & gravity.

|Note:
  1. Say /zm to open zombie classes menu.
  2. Open your zombie_escape.txt & add at the end of it:

    Code: Select all

    MENU_ZCLASS = \rChoose Zombie Class \d|
    NO_ZCLASSES = !tThere aren't classes available!y.
    ZOMBIE_SELECT = Your next zombie class is going to be
    ZOMBIE_HEALTH = Health
    ZOMBIE_SPEED = Speed
    ZOMBIE_GRAVITY = Gravity

|Guide:
  • This plugin doesn't support different models for each class like ZP so if you want models use Special Models.

|Code:
  1. ze_zombie_class.sma
    1. #include <zombie_escape>
    2. #include <ze_zombie_class_const>
    3.  
    4. new const ZE_ZOMBIECLASSES_FILE[] = "ze_zombieclasses.ini"
    5.  
    6. #define ZOMBIES_DEFAULT_NAME "Zombie"
    7. #define ZOMBIES_DEFAULT_DESCRIPTION "Classic"
    8. #define ZOMBIES_DEFAULT_HEALTH 1800
    9. #define ZOMBIES_DEFAULT_SPEED 315
    10. #define ZOMBIES_DEFAULT_GRAVITY 800
    11.  
    12. const OFFSET_CSMENUCODE = 205
    13.  
    14. // For class list menu handlers
    15. #define MENU_PAGE_CLASS g_menu_data[id]
    16. new g_menu_data[33]
    17.  
    18. enum _:TOTAL_FORWARDS
    19. {
    20.     FW_SELECT_CLASS_PRE = 0,
    21.     FW_SELECT_CLASS_POST
    22. }
    23. new g_iForwards[TOTAL_FORWARDS], g_iForwardResult
    24.  
    25. new Array:g_szZombieClassRealName,
    26.     Array:g_szZombieClassName,
    27.     Array:g_szZombieClassDesc,
    28.     Array:g_iZombieClassHealth,
    29.     Array:g_iZombieClassSpeed,
    30.     Array:g_flZombieClassGravity
    31.  
    32. new g_iZombieClass[33], g_iNextZombieClass[33], g_szAdditionalMenuText[32], g_iZombieClassNumber
    33.  
    34. public plugin_natives()
    35. {
    36.     register_native("ze_get_current_zombie_class", "native_ze_get_current_zombie_class", 1)
    37.     register_native("ze_get_next_zombie_class", "native_ze_get_next_zombie_class", 1)
    38.     register_native("ze_set_next_zombie_class", "native_ze_set_next_zombie_class", 1)
    39.     register_native("ze_get_zombie_class_health", "native_ze_get_zombie_class_health", 1)
    40.     register_native("ze_register_zombie_class", "native_ze_register_zombie_class")
    41.     register_native("ze_get_zombie_class_id", "native_ze_get_zombie_class_id", 1)
    42.     register_native("ze_get_zombie_class_name", "native_ze_get_zombie_class_name")
    43.     register_native("ze_get_zombie_class_desc", "native_ze_get_zombie_class_desc")
    44.     register_native("ze_get_zombie_class_number", "native_ze_get_zombie_class_number", 1)
    45.     register_native("ze_open_zombie_classes_menu", "native_ze_open_zombie_classes_menu", 1)
    46.     register_native("ze_add_zombie_class_menu_text", "native_ze_add_zombie_class_menu_text", 1)
    47.  
    48.     g_szZombieClassRealName = ArrayCreate(32, 1)
    49.     g_szZombieClassName = ArrayCreate(32, 1)
    50.     g_szZombieClassDesc = ArrayCreate(32, 1)
    51.     g_iZombieClassHealth = ArrayCreate(1, 1)
    52.     g_iZombieClassSpeed = ArrayCreate(1, 1)
    53.     g_flZombieClassGravity = ArrayCreate(1, 1)
    54. }
    55.  
    56. public plugin_init()
    57. {
    58.     register_plugin("[ZE] Addons: Zombie Classes", "1.0", "Jack GamePlay")
    59.  
    60.     register_clcmd("say /zm", "Show_Zombie_Classes_Menu")
    61.    
    62.     g_iForwards[FW_SELECT_CLASS_PRE] = CreateMultiForward("ze_select_zombie_class_pre", ET_CONTINUE, FP_CELL, FP_CELL)
    63.     g_iForwards[FW_SELECT_CLASS_POST] = CreateMultiForward("ze_select_zombie_class_post", ET_CONTINUE, FP_CELL, FP_CELL)
    64. }
    65.  
    66. public plugin_cfg()
    67. {
    68.     if (g_iZombieClassNumber < 1)
    69.     {
    70.         ArrayPushString(g_szZombieClassRealName, ZOMBIES_DEFAULT_NAME)
    71.         ArrayPushString(g_szZombieClassName, ZOMBIES_DEFAULT_NAME)
    72.         ArrayPushString(g_szZombieClassDesc, ZOMBIES_DEFAULT_DESCRIPTION)
    73.         ArrayPushCell(g_iZombieClassHealth, ZOMBIES_DEFAULT_HEALTH)
    74.         ArrayPushCell(g_iZombieClassSpeed, ZOMBIES_DEFAULT_SPEED)
    75.         ArrayPushCell(g_flZombieClassGravity, ZOMBIES_DEFAULT_GRAVITY)
    76.         g_iZombieClassNumber++
    77.     }
    78. }
    79.  
    80. public client_putinserver(id)
    81. {
    82.     g_iZombieClass[id] = ZE_WRONG_ZOMBIE_CLASS
    83.     g_iNextZombieClass[id] = ZE_WRONG_ZOMBIE_CLASS
    84. }
    85.  
    86. public client_disconnected(id)
    87. {
    88.     MENU_PAGE_CLASS = 0
    89. }
    90.  
    91. public Show_Zombie_Classes_Menu(id)
    92. {
    93.     static szMenu[128], szClassName[32], szClassDesc[32]
    94.     new iMenuID, iItemData[2], iIndex
    95.    
    96.     formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "MENU_ZCLASS")
    97.     iMenuID = menu_create(szMenu, "ZombieClassesMenuHandler")
    98.    
    99.     for (iIndex = 0; iIndex < g_iZombieClassNumber; iIndex++)
    100.     {
    101.         // Additional text to display
    102.         g_szAdditionalMenuText[0] = 0
    103.        
    104.         // Execute class select attempt forward
    105.         ExecuteForward(g_iForwards[FW_SELECT_CLASS_PRE], g_iForwardResult, id, iIndex)
    106.        
    107.         // Show class to player?
    108.         if (g_iForwardResult >= ZE_CLASS_DONT_SHOW)
    109.             continue
    110.        
    111.         ArrayGetString(g_szZombieClassName, iIndex, szClassName, charsmax(szClassName))
    112.         ArrayGetString(g_szZombieClassDesc, iIndex, szClassDesc, charsmax(szClassDesc))
    113.        
    114.         // Class available to player?
    115.         if (g_iForwardResult >= ZE_CLASS_UNAVAILABLE)
    116.             formatex(szMenu, charsmax(szMenu), "\d%s | %s | %s", szClassName, szClassDesc, g_szAdditionalMenuText)
    117.         // Class is current class?
    118.         else if (iIndex == g_iNextZombieClass[id])
    119.             formatex(szMenu, charsmax(szMenu), "\w%s \d| \y%s \d[\yCurrent\d] \r%s", szClassName, szClassDesc, g_szAdditionalMenuText)
    120.         else
    121.             formatex(szMenu, charsmax(szMenu), "\y%s \d| \w%s \r%s", szClassName, szClassDesc, g_szAdditionalMenuText)
    122.        
    123.         iItemData[0] = iIndex
    124.         iItemData[1] = 0
    125.         menu_additem(iMenuID, szMenu, iItemData)
    126.     }
    127.    
    128.     // No classes to display?
    129.     if (menu_items(iMenuID) <= 0)
    130.     {
    131.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_ZCLASSES")
    132.         menu_destroy(iMenuID)
    133.         return
    134.     }
    135.    
    136.     // Back - Next - Exit
    137.     formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "BACK")
    138.     menu_setprop(iMenuID, MPROP_BACKNAME, szMenu)
    139.     formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "NEXT")
    140.     menu_setprop(iMenuID, MPROP_NEXTNAME, szMenu)
    141.     formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "EXIT")
    142.     menu_setprop(iMenuID, MPROP_EXITNAME, szMenu)
    143.    
    144.     MENU_PAGE_CLASS = min(MENU_PAGE_CLASS, menu_pages(iMenuID) - 1)
    145.    
    146.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    147.     menu_display(id, iMenuID, MENU_PAGE_CLASS)
    148. }
    149.  
    150. public ZombieClassesMenuHandler(id, iMenuID, iItemID)
    151. {
    152.     // Menu was closed
    153.     if (iItemID == MENU_EXIT)
    154.     {
    155.         MENU_PAGE_CLASS = 0
    156.         menu_destroy(iMenuID)
    157.         return PLUGIN_HANDLED
    158.     }
    159.    
    160.     // Remember class menu page
    161.     MENU_PAGE_CLASS = iItemID / 7
    162.    
    163.     // Retrieve class index
    164.     new iItemData[2], iDummy, iIndex
    165.     menu_item_getinfo(iMenuID, iItemID, iDummy, iItemData, charsmax(iItemData), _, _, iDummy)
    166.     iIndex = iItemData[0]
    167.    
    168.     // Execute class select attempt forward
    169.     ExecuteForward(g_iForwards[FW_SELECT_CLASS_PRE], g_iForwardResult, id, iIndex)
    170.    
    171.     // Class available to player?
    172.     if (g_iForwardResult >= ZE_CLASS_UNAVAILABLE)
    173.     {
    174.         menu_destroy(iMenuID)
    175.         return PLUGIN_HANDLED
    176.     }
    177.    
    178.     // Make selected class next class for player
    179.     g_iNextZombieClass[id] = iIndex
    180.    
    181.     new szClassName[32]
    182.     ArrayGetString(g_szZombieClassName, g_iNextZombieClass[id], szClassName, charsmax(szClassName))
    183.    
    184.     ze_colored_print(id, "!t%L!y: !g%s", LANG_PLAYER, "ZOMBIE_SELECT", szClassName)
    185.     ze_colored_print(id, "!t%L!y: !g%i !y- !t%L!y: !g%i !y- !t%L!y: !g%i", LANG_PLAYER, "ZOMBIE_HEALTH", ArrayGetCell(g_iZombieClassHealth, g_iNextZombieClass[id]), LANG_PLAYER, "ZOMBIE_SPEED", ArrayGetCell(g_iZombieClassSpeed, g_iNextZombieClass[id]), LANG_PLAYER, "ZOMBIE_GRAVITY", ArrayGetCell(g_flZombieClassGravity, g_iNextZombieClass[id]))
    186.    
    187.     // Execute class select post forward
    188.     ExecuteForward(g_iForwards[FW_SELECT_CLASS_POST], g_iForwardResult, id, iIndex)
    189.    
    190.     menu_destroy(iMenuID)
    191.     return PLUGIN_HANDLED
    192. }
    193.  
    194. public ze_user_infected(id)
    195. {
    196.     // Show zombie class menu if they haven't chosen any (e.g. just connected)
    197.     if (g_iNextZombieClass[id] == ZE_WRONG_ZOMBIE_CLASS)
    198.     {
    199.         if (g_iZombieClassNumber > 1)
    200.             Show_Zombie_Classes_Menu(id)
    201.         else // If only one class is registered, choose it automatically
    202.             g_iNextZombieClass[id] = 0
    203.     }
    204.    
    205.     // Bots pick class automatically
    206.     if (is_user_bot(id))
    207.     {
    208.         // Try choosing class
    209.         new iIndex, iStart_Index = random_num(0, g_iZombieClassNumber - 1)
    210.         for (iIndex = iStart_Index + 1; /* no condition */; iIndex++)
    211.         {
    212.             // Start over when we reach the end
    213.             if (iIndex >= g_iZombieClassNumber)
    214.                 iIndex = 0
    215.            
    216.             // Execute class select attempt forward
    217.             ExecuteForward(g_iForwards[FW_SELECT_CLASS_PRE], g_iForwardResult, id, iIndex)
    218.            
    219.             // Class available to player?
    220.             if (g_iForwardResult < ZE_CLASS_UNAVAILABLE)
    221.             {
    222.                 g_iNextZombieClass[id] = iIndex
    223.                 break
    224.             }
    225.            
    226.             // Loop completed, no class could be chosen
    227.             if (iIndex == iStart_Index)
    228.                 break
    229.         }
    230.     }
    231.    
    232.     // Set selected zombie class. If none selected yet, use the first one
    233.     g_iZombieClass[id] = g_iNextZombieClass[id]
    234.     if (g_iZombieClass[id] == ZE_WRONG_ZOMBIE_CLASS)
    235.             g_iZombieClass[id] = 0
    236.    
    237.     // Apply zombie attributes
    238.     set_entvar(id, var_health, float(ArrayGetCell(g_iZombieClassHealth, g_iZombieClass[id])))
    239.     set_entvar(id, var_gravity, float(ArrayGetCell(g_flZombieClassGravity, g_iZombieClass[id])) / 800)
    240.     ze_set_zombie_speed(id, ArrayGetCell(g_iZombieClassSpeed, g_iZombieClass[id]))
    241. }
    242.  
    243. public native_ze_get_current_zombie_class(id)
    244. {
    245.     if (!is_user_connected(id))
    246.     {
    247.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    248.         return ZE_WRONG_ZOMBIE_CLASS
    249.     }
    250.    
    251.     return g_iZombieClass[id]
    252. }
    253.  
    254. public native_ze_get_next_zombie_class(id)
    255. {
    256.     if (!is_user_connected(id))
    257.     {
    258.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    259.         return ZE_WRONG_ZOMBIE_CLASS
    260.     }
    261.    
    262.     return g_iNextZombieClass[id]
    263. }
    264.  
    265. public native_ze_set_next_zombie_class(id, iClassID)
    266. {
    267.     if (!is_user_connected(id))
    268.     {
    269.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    270.         return false
    271.     }
    272.    
    273.     if (0 > iClassID >= g_iZombieClassNumber)
    274.     {
    275.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid zombie class id (%d)", iClassID)
    276.         return false
    277.     }
    278.    
    279.     g_iNextZombieClass[id] = iClassID
    280.     return true
    281. }
    282.  
    283. public native_ze_get_zombie_class_health(id, iClassID)
    284. {
    285.     if (!is_user_connected(id))
    286.     {
    287.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    288.         return -1
    289.     }
    290.    
    291.     if (0 > iClassID >= g_iZombieClassNumber)
    292.     {
    293.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid zombie class id (%d)", iClassID)
    294.         return -1
    295.     }
    296.    
    297.     return ArrayGetCell(g_iZombieClassHealth, iClassID)
    298. }
    299.  
    300. public native_ze_register_zombie_class(plugin_id, num_params)
    301. {
    302.     new szName[32]
    303.     get_string(1, szName, charsmax(szName))
    304.    
    305.     if (strlen(szName) < 1)
    306.     {
    307.         log_error(AMX_ERR_NATIVE, "[ZE] Can't register zombie class with an empty name")
    308.         return ZE_WRONG_ZOMBIE_CLASS
    309.     }
    310.    
    311.     new iIndex, szZombieClassName[32]
    312.     for (iIndex = 0; iIndex < g_iZombieClassNumber; iIndex++)
    313.     {
    314.         ArrayGetString(g_szZombieClassRealName, iIndex, szZombieClassName, charsmax(szZombieClassName))
    315.         if (equali(szName, szZombieClassName))
    316.         {
    317.             log_error(AMX_ERR_NATIVE, "[ZE] Zombie class already registered (%s)", szName)
    318.             return ZE_WRONG_ZOMBIE_CLASS
    319.         }
    320.     }
    321.    
    322.     new szDesc[32]
    323.     get_string(2, szDesc, charsmax(szDesc))
    324.     new iHealth = get_param(3)
    325.     new iSpeed = get_param(4)
    326.     new flGravity = get_param(5)
    327.  
    328.     // Load settings from zombie classes file
    329.     new szRealName[32]
    330.     copy(szRealName, charsmax(szRealName), szName)
    331.     ArrayPushString(g_szZombieClassRealName, szRealName)
    332.  
    333.     // Name
    334.     if (!amx_load_setting_string(ZE_ZOMBIECLASSES_FILE, szRealName, "NAME", szName, charsmax(szName)))
    335.         amx_save_setting_string(ZE_ZOMBIECLASSES_FILE, szRealName, "NAME", szName)
    336.     ArrayPushString(g_szZombieClassName, szName)
    337.    
    338.     // Description
    339.     if (!amx_load_setting_string(ZE_ZOMBIECLASSES_FILE, szRealName, "INFO", szDesc, charsmax(szDesc)))
    340.         amx_save_setting_string(ZE_ZOMBIECLASSES_FILE, szRealName, "INFO", szDesc)
    341.     ArrayPushString(g_szZombieClassDesc, szDesc)
    342.    
    343.     // Health
    344.     if (!amx_load_setting_int(ZE_ZOMBIECLASSES_FILE, szRealName, "HEALTH", iHealth))
    345.         amx_save_setting_int(ZE_ZOMBIECLASSES_FILE, szRealName, "HEALTH", iHealth)
    346.     ArrayPushCell(g_iZombieClassHealth, iHealth)
    347.    
    348.     // Speed
    349.     if (!amx_load_setting_int(ZE_ZOMBIECLASSES_FILE, szRealName, "SPEED", iSpeed))
    350.         amx_save_setting_int(ZE_ZOMBIECLASSES_FILE, szRealName, "SPEED", iSpeed)
    351.     ArrayPushCell(g_iZombieClassSpeed, iSpeed)
    352.    
    353.     // Gravity
    354.     if (!amx_load_setting_int(ZE_ZOMBIECLASSES_FILE, szRealName, "GRAVITY", flGravity))
    355.         amx_load_setting_int(ZE_ZOMBIECLASSES_FILE, szRealName, "GRAVITY", flGravity)
    356.     ArrayPushCell(g_flZombieClassGravity, flGravity)
    357.    
    358.     g_iZombieClassNumber++
    359.     return g_iZombieClassNumber - 1
    360. }
    361.  
    362. public native_ze_get_zombie_class_id(const szName[])
    363. {
    364.     new iIndex, szZombieClassName[32]
    365.     for (iIndex = 0; iIndex < g_iZombieClassNumber; iIndex++)
    366.     {
    367.         ArrayGetString(g_szZombieClassRealName, iIndex, szZombieClassName, charsmax(szZombieClassName))
    368.         if (equali(szName, szZombieClassName))
    369.             return iIndex
    370.     }
    371.    
    372.     return ZE_WRONG_ZOMBIE_CLASS
    373. }
    374.  
    375. public native_ze_get_zombie_class_name(plugin_id, num_params)
    376. {
    377.     new iClassID = get_param(1)
    378.    
    379.     if (0 > iClassID >= g_iZombieClassNumber)
    380.     {
    381.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid zombie class id (%d)", iClassID)
    382.         return false
    383.     }
    384.    
    385.     new szName[32]
    386.     ArrayGetString(g_szZombieClassName, iClassID, szName, charsmax(szName))
    387.    
    388.     new iLen = get_param(3)
    389.     set_string(2, szName, iLen)
    390.     return true
    391. }
    392.  
    393. public native_ze_get_zombie_class_desc(plugin_id, num_params)
    394. {
    395.     new iClassID = get_param(1)
    396.    
    397.     if (0 > iClassID >= g_iZombieClassNumber)
    398.     {
    399.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid zombie class id (%d)", iClassID)
    400.         return false
    401.     }
    402.    
    403.     new szDesc[32]
    404.     ArrayGetString(g_szZombieClassDesc, iClassID, szDesc, charsmax(szDesc))
    405.    
    406.     new iLen = get_param(3)
    407.     set_string(2, szDesc, iLen)
    408.     return true
    409. }
    410.  
    411. public native_ze_get_zombie_class_number()
    412. {
    413.     return g_iZombieClassNumber
    414. }
    415.  
    416. public native_ze_open_zombie_classes_menu(id)
    417. {
    418.     if (!is_user_connected(id))
    419.     {
    420.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    421.         return false
    422.     }
    423.    
    424.     Show_Zombie_Classes_Menu(id)
    425.     return true
    426. }
    427.  
    428. public native_ze_add_zombie_class_menu_text(const text[])
    429. {
    430.     format(g_szAdditionalMenuText, charsmax(g_szAdditionalMenuText), "%s%s", g_szAdditionalMenuText, text)
    431. }
  2. ze_zombie_class.inc
    1. #include <ze_zombie_class_const>
    2.  
    3. /*****************************************/
    4. /************   FORWARDS    **************/
    5. /*****************************************/
    6.  
    7. /**
    8.  * Called when determining whether a class should be available to a player.
    9.  *
    10.  * Possible return values are:
    11.  *  - ZE_CLASS_AVAILABLE (show in menu, allow selection)
    12.  *  - ZE_CLASS_UNAVAILABLE (show in menu, don't allow selection)
    13.  *  - ZE_CLASS_DONT_SHOW (don't show in menu, don't allow selection)
    14.  *
    15.  * @param id            Player index.
    16.  * @param classid       Internal zombie class ID.
    17.  */
    18. forward ze_select_zombie_class_pre(id, classid)
    19.  
    20. /**
    21.  * Called right after a player selects a class from the menu.
    22.  *
    23.  * @param id            Player index.
    24.  * @param classid       Internal zombie class ID.
    25.  */
    26. forward ze_select_zombie_class_post(id, classid)
    27.  
    28. /*****************************************/
    29. /************** NATIVES ******************/
    30. /*****************************************/
    31.  
    32. /**
    33.  * Returns a player's current zombie class ID.
    34.  *
    35.  * @param id        Player index.
    36.  * @return          Internal zombie class ID, or ZE_WRONG_ZOMBIE_CLASS if not yet chosen.
    37.  */
    38. native ze_get_current_zombie_class(id)
    39.  
    40. /**
    41.  * Returns a player's next zombie class ID (for the next infection).
    42.  *
    43.  * @param id        Player index.
    44.  * @return          Internal zombie class ID, or ZE_WRONG_ZOMBIE_CLASS if not yet chosen.
    45.  */
    46. native ze_get_next_zombie_class(id)
    47.  
    48. /**
    49.  * Sets a player's next zombie class ID (for the next infection).
    50.  *
    51.  * @param id        Player index.
    52.  * @param classid   A valid zombie class ID.
    53.  * @return          True on success, false otherwise.
    54.  */
    55. native ze_set_next_zombie_class(id, classid)
    56.  
    57. /**
    58.  * Returns the default maximum health for a specific zombie class.
    59.  *
    60.  * Note: does not take into account any kind of HP multipliers.
    61.  *
    62.  * @param id        Player index.
    63.  * @param classid   A valid zombie class ID.
    64.  * @return          Maximum amount of health points, -1 on error.
    65.  */
    66. native ze_get_zombie_class_health(id, classid)
    67.  
    68. /**
    69.  * Registers a custom class which will be added to the zombie classes menu of ZP.
    70.  *
    71.  * Note: The returned zombie class ID can be later used to identify
    72.  * the class when calling the zp_get_user_zombie_class() natives.
    73.  *
    74.  * @param name          Caption to display on the menu.
    75.  * @param description   Brief description of the class.
    76.  * @param health        Class health.
    77.  * @param speed         Class maxspeed (can be a multiplier).
    78.  * @param gravity       Class gravity multiplier.
    79.  * @return              An internal zombie class ID, or ZE_WRONG_ZOMBIE_CLASS on failure.
    80.  */
    81. native ze_register_zombie_class(const name[], const description[], health, speed, gravity)
    82.  
    83. /**
    84.  * Returns a zombie class' ID.
    85.  *
    86.  * @param name      Class name to look for.
    87.  * @return          Internal zombie class ID, or ZE_WRONG_ZOMBIE_CLASS if not found.
    88.  */
    89. native ze_get_zombie_class_id(const real_name[])
    90.  
    91. /**
    92.  * Returns a zombie class' name.
    93.  *
    94.  * @param classid   A valid zombie class ID.
    95.  * @param name      The buffer to store the string in.
    96.  * @param len       Character size of the output buffer.
    97.  * @return          True on success, false otherwise.
    98.  */
    99. native ze_get_zombie_class_name(classid, name[], len)
    100.  
    101. /**
    102.  * Returns a zombie class' description.
    103.  *
    104.  * @param classid       A valid zombie class ID.
    105.  * @param description   The buffer to store the string in.
    106.  * @param len           Character size of the output buffer.
    107.  * @return              True on success, false otherwise.
    108.  */
    109. native ze_get_zombie_class_desc(classid, description[], len)
    110.  
    111. /**
    112.  * Returns number of registered zombie classes.
    113.  *
    114.  * @return          Zombie class count.
    115.  */
    116. native ze_get_zombie_class_number()
    117.  
    118. /**
    119.  * Shows menu with available zombie classes to a player.
    120.  *
    121.  * @param id        Player index.
    122.  */
    123. native ze_open_zombie_classes_menu(id)
    124.  
    125. /**
    126.  * Appends text to a class being displayed on the zombie classes menu.
    127.  * Use this on the class select pre forward.
    128.  *
    129.  * @param text      Additional text to display.
    130.  */
    131. native ze_add_zombie_class_menu_text(const text[])
  3. ze_zombie_class_const.inc
    1. /* Zombie Class ID constants */
    2. #define ZE_WRONG_ZOMBIE_CLASS -1
    3.  
    4. /* Class selection constants */
    5. #define ZE_CLASS_AVAILABLE 0
    6. #define ZE_CLASS_UNAVAILABLE 1
    7. #define ZE_CLASS_DONT_SHOW 2

Re: Zombie classes

Posted: 26 Jul 2018, 02:44
by Rain1153
So u mean the classes are limited only to speed,gravity and health....what if we want to install custom classes

Re: Zombie classes

Posted: 26 Jul 2018, 03:52
by Night Fury
Rain1153 wrote: 5 years ago So u mean the classes are limited only to speed,gravity and health....what if we want to install custom classes
You can use ZP classes by converting them. It's the same as ZP but no models or claw models as they are available in special models as i said.

Re: Zombie classes

Posted: 28 Jul 2018, 04:07
by Rain1153
and why is there no zombie classes.ini?

Re: Zombie classes

Posted: 28 Jul 2018, 05:25
by Rain1153
i wanted to add custom classes by changing the values of speed gravity and stuff but i cant becz there is no classes.ini file

Re: Zombie classes

Posted: 28 Jul 2018, 07:38
by Night Fury
Rain1153 wrote: 5 years ago and why is there no zombie classes.ini?
There is but it's automatically added.

Re: Zombie classes

Posted: 28 Jul 2018, 07:38
by Rain1153
It didnt add in the server config folder

Re: Zombie classes

Posted: 28 Jul 2018, 09:48
by Night Fury
Rain1153 wrote: 5 years ago It didnt add in the server config folder
It will be added once you add zombie classes.

Re: Zombie classes

Posted: 28 Jul 2018, 09:49
by Rain1153
but it didn't come :/

Re: Zombie classes

Posted: 28 Jul 2018, 09:55
by Rain1153
please find a way to add other zm classes

Re: Zombie classes

Posted: 28 Jul 2018, 10:04
by Night Fury
Rain1153 wrote: 5 years ago but it didn't come :/
Add this hunter will (will be shared later) & test it.
PS: use the same sound in speed boost plugin.

| Code:

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

Re: Zombie classes

Posted: 28 Jul 2018, 10:13
by Rain1153
You are mistaked bro...wait can you add 3 new default classes in ze class.sma? So that i can edit it from the source through defines?
Like in zp there r default 4 classes
And pls see why the ini file is not auto generated

Re: Zombie classes

Posted: 28 Jul 2018, 10:27
by Night Fury
Rain1153 wrote: 5 years ago You are mistaked bro...wait can you add 3 new default classes in ze class.sma? So that i can edit it from the source through defines?
Like in zp there r default 4 classes
And pls see why the ini file is not auto generated
The INI file is auto generated if it doesn't exist & if any plugin ran & has this native in it:

Code: Select all

native ze_register_zombie_class
We put a default zombie class in the source so it's used when there are not any added zombie classes but if there is any zombie classes, default ZClasses will be useless. Just use the hunter class i have provided you & you will understand.

Re: Zombie classes

Posted: 28 Jul 2018, 11:17
by Rain1153
so i will try to convert other zp classes too

Re: Zombie classes

Posted: 28 Jul 2018, 13:17
by johnnysins2000
we can convert zp classes into ze ?

Re: Zombie classes

Posted: 28 Jul 2018, 13:22
by Night Fury
johnnysins2000 wrote: 5 years ago we can convert zp classes into ze ?
Yes.

Re: Zombie classes

Posted: 28 Jul 2018, 13:39
by johnnysins2000
Jack GamePlay wrote: 5 years ago
johnnysins2000 wrote: 5 years ago we can convert zp classes into ze ?
Yes.
a tutorial would be good in tutorials section ?

any chances of making it ? or atleast tell me which natives i can use to convert zp classes to ze?

Re: Zombie classes

Posted: 28 Jul 2018, 13:54
by Night Fury
johnnysins2000 wrote: 5 years ago
a tutorial would be good in tutorials section ?

any chances of making it ? or at least tell me which natives i can use to convert zp classes to ze?
Check the include file & you will find all natives & forwards.
I will make a tutorial.
I'm sharing examples.

Re: Zombie classes

Posted: 04 Nov 2018, 14:14
by DarkZombie
ze_zombie_class.sma can not be converted to amxx, this is the error: (image)

Re: Zombie classes

Posted: 04 Nov 2018, 21:37
by Night Fury
DarkZombie wrote: 5 years ago ze_zombie_class.sma can not be converted to amxx, this is the error: (image)
Make a new file called "zombie_class_const.inc" & put in it the code in the first post.