Resolved Ze Madness Limit

Coding Help/Re-API Supported
Post Reply
johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

Ze Madness Limit

#1

Post by johnnysins2000 » 2 Years Ago

Hello Guyz today i was trying to put ZE madness but i think since i do not have that much information but still i tried and tested it but i could still again take the ze madness

What Do I want?

It is Simple.All i want is like zp has limit of buying zombie madness per round i wanted also same

Code:
    1. #include <zombie_escape>
    2.  
    3. // Setting File
    4. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
    5.  
    6. // Default Values
    7. new const szZombieMadnessSound[][] =
    8. {
    9.     "zombie_escape/zombie_madness1.wav"
    10. }
    11.  
    12. // Sound Max Length
    13. #define SOUND_MAX_LENGTH 64
    14.  
    15. // Dynamic Array to Store our sound in
    16. new Array:g_szZombie_Madness_Sound
    17.  
    18. // Task IDs
    19. #define TASK_MADNESS 100
    20. #define TASK_AURA 200
    21. #define ID_MADNESS (taskid - TASK_MADNESS)
    22. #define ID_AURA (taskid - TASK_AURA)
    23.  
    24. // Variables
    25. new g_iItemID, bool:g_bZombieInMadness[33] , g_madnesscounter  
    26.  
    27. // Cvars
    28. new Cvar_Madness_Time, Cvar_Madness_Aura_Red, Cvar_Madness_Aura_Green, Cvar_Madness_Aura_Blue , Cvar_Madness_limit
    29.  
    30. public plugin_init()
    31. {
    32.     register_plugin("[ZE] Items: Zombie Madness", ZE_VERSION, AUTHORS)
    33.    
    34.     // Hook Chains
    35.     RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
    36.     RegisterHookChain(RG_CBasePlayer_Spawn, "Fw_PlayerSpawn_Post", 1)
    37.     RegisterHookChain(RG_CBasePlayer_Killed, "Fw_PlayerKilled_Post", 1)
    38.    
    39.     // Register our item
    40.     g_iItemID = ze_register_item("Zombie Madness", 15)
    41.    
    42.     // Cvars
    43.     Cvar_Madness_Time = register_cvar("ze_madness_time", "5.0")
    44.     Cvar_Madness_Aura_Red = register_cvar("ze_madness_color_red", "255")
    45.     Cvar_Madness_Aura_Green = register_cvar("ze_madness_color_green", "0")
    46.     Cvar_Madness_Aura_Blue = register_cvar("ze_madness_color_blue", "0")
    47.     Cvar_Madness_limit = register_cvar("ze_madness_limit", "2")
    48.    
    49. }
    50.  
    51. public plugin_precache()
    52. {
    53.     // Initialize arrays
    54.     g_szZombie_Madness_Sound = ArrayCreate(SOUND_MAX_LENGTH, 1)
    55.    
    56.     // Load from external file
    57.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "ZOMBIE MADNESS", g_szZombie_Madness_Sound)
    58.    
    59.     // If we couldn't load custom sounds from file, use and save default ones
    60.    
    61.     new iIndex
    62.    
    63.     if (ArraySize(g_szZombie_Madness_Sound) == 0)
    64.     {
    65.         for (iIndex = 0; iIndex < sizeof szZombieMadnessSound; iIndex++)
    66.             ArrayPushString(g_szZombie_Madness_Sound, szZombieMadnessSound[iIndex])
    67.        
    68.         // Save to external file
    69.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "ZOMBIE MADNESS", g_szZombie_Madness_Sound)
    70.     }
    71.    
    72.     // Precache sounds
    73.     new szSound[SOUND_MAX_LENGTH]
    74.     for (iIndex = 0; iIndex < ArraySize(g_szZombie_Madness_Sound); iIndex++)
    75.     {
    76.         ArrayGetString(g_szZombie_Madness_Sound, iIndex, szSound, charsmax(szSound))
    77.         precache_sound(szSound)
    78.     }
    79. }
    80.  
    81. public plugin_natives()
    82. {
    83.     register_native("ze_zombie_in_madness", "native_ze_zombie_in_madness")
    84. }
    85.  
    86. public ze_select_item_pre(id, itemid)
    87. {
    88.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    89.     if (itemid != g_iItemID)
    90.         return ZE_ITEM_AVAILABLE
    91.    
    92.     // Zombie madness only available to zombies
    93.     if (!ze_is_user_zombie(id))
    94.         return ZE_ITEM_DONT_SHOW
    95.    
    96.     // Player already has madness
    97.     if (g_bZombieInMadness[id])
    98.         return ZE_ITEM_UNAVAILABLE
    99.    
    100.     return ZE_ITEM_AVAILABLE
    101. }
    102.  
    103. public ze_select_item_post(id, itemid)
    104. {
    105.     // This is not our item, Block it here
    106.     if (itemid != g_iItemID)
    107.         return
    108.        
    109.     // Increase madness purchase count for this round
    110.           g_madnesscounter++
    111.      
    112.     // Check for unavailable items
    113.     get_pcvar_num(Cvar_Madness_limit)
    114.    
    115.     // Player In Madness
    116.     g_bZombieInMadness[id] = true
    117.    
    118.     // Madness aura
    119.     set_task(0.1, "Madness_Aura", id+TASK_AURA, _, _, "b")
    120.    
    121.     // Madness sound
    122.     new szSound[SOUND_MAX_LENGTH]
    123.     ArrayGetString(g_szZombie_Madness_Sound, random_num(0, ArraySize(g_szZombie_Madness_Sound) - 1), szSound, charsmax(szSound))
    124.     emit_sound(id, CHAN_VOICE, szSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    125.    
    126.     // Set task to remove it
    127.     set_task(get_pcvar_float(Cvar_Madness_Time), "Remove_Zombie_Madness", id+TASK_MADNESS)
    128. }
    129.  
    130. // Player Spawn
    131. public Fw_PlayerSpawn_Post(id)
    132. {
    133.     // Not alive or didn't join a team yet
    134.     if (!is_user_alive(id) || !get_member(id, m_iTeam))
    135.         return
    136.    
    137.     // Remove zombie madness from a previous round
    138.     remove_task(id+TASK_MADNESS)
    139.     remove_task(id+TASK_AURA)
    140.     g_bZombieInMadness[id] = false
    141. }
    142.  
    143. // Trace Attack
    144. public Fw_TraceAttack_Pre(iVictim, iAttacker)
    145. {
    146.     // Allow Player to damage himself or Die From map bombs
    147.     if (iVictim == iAttacker || !is_user_alive(iAttacker))
    148.         return HC_CONTINUE
    149.    
    150.     // Prevent attacks when victim has zombie madness
    151.     if (g_bZombieInMadness[iVictim])
    152.         return HC_SUPERCEDE
    153.    
    154.     return HC_CONTINUE
    155. }
    156.  
    157. public ze_frost_pre(id)
    158. {
    159.     // Prevent frost when victim has zombie madness
    160.     if (g_bZombieInMadness[id])
    161.         return PLUGIN_HANDLED
    162.    
    163.     return PLUGIN_CONTINUE
    164. }
    165.  
    166. public ze_fire_pre(id)
    167. {
    168.     // Prevent burning when victim has zombie madness
    169.     if (g_bZombieInMadness[id])
    170.         return PLUGIN_HANDLED
    171.    
    172.     return PLUGIN_CONTINUE
    173. }
    174.  
    175. public ze_user_humanized(id)
    176. {
    177.     // Remove zombie madness task if player somehow became human while he still in madness
    178.     remove_task(id+TASK_MADNESS)
    179.     remove_task(id+TASK_AURA)
    180.     g_bZombieInMadness[id] = false
    181. }
    182.  
    183. // Player Killed
    184. public Fw_PlayerKilled_Post(iVictim)
    185. {
    186.     // Remove zombie madness task
    187.     remove_task(iVictim+TASK_MADNESS)
    188.     remove_task(iVictim+TASK_AURA)
    189.     g_bZombieInMadness[iVictim] = false
    190. }
    191.  
    192. // Remove Madness
    193. public Remove_Zombie_Madness(taskid)
    194. {
    195.     // Remove aura
    196.     remove_task(ID_MADNESS+TASK_AURA)
    197.  
    198.     // Remove zombie madness
    199.     g_bZombieInMadness[ID_MADNESS] = false
    200. }
    201.  
    202. public client_disconnect(id)
    203. {
    204.     // Remove tasks on disconnect
    205.     remove_task(id+TASK_MADNESS)
    206.     remove_task(id+TASK_AURA)
    207.     g_bZombieInMadness[id] = false
    208. }
    209.  
    210. // Madness aura task
    211. public Madness_Aura(taskid)
    212. {
    213.     // Get player's origin
    214.     static origin[3]
    215.     get_user_origin(ID_AURA, origin)
    216.    
    217.     // Colored Aura
    218.     message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
    219.     write_byte(TE_DLIGHT) // TE id
    220.     write_coord(origin[0]) // x
    221.     write_coord(origin[1]) // y
    222.     write_coord(origin[2]) // z
    223.     write_byte(20) // radius
    224.     write_byte(get_pcvar_num(Cvar_Madness_Aura_Red)) // r
    225.     write_byte(get_pcvar_num(Cvar_Madness_Aura_Green)) // g
    226.     write_byte(get_pcvar_num(Cvar_Madness_Aura_Blue)) // b
    227.     write_byte(2) // life
    228.     write_byte(0) // decay rate
    229.     message_end()
    230. }
    231.  
    232. public native_ze_zombie_in_madness(id)
    233. {
    234.     if (!is_user_alive(id))
    235.     {
    236.         // Throw Error and return false if player isn't alive
    237.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    238.         return false
    239.     }
    240.    
    241.     return g_bZombieInMadness[id]
    242. }
Nobody Is That Busy If They Make Time :roll:

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#2

Post by johnnysins2000 » 2 Years Ago

I also want to learn same for other ze zombie extra items put the Limit in them .So when i post a ze zombie extra item i could also add limit to them
Nobody Is That Busy If They Make Time :roll:

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 622
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 48 times
Age: 19
Contact:

#3

Post by Mohamed Alaa » 2 Years Ago

Code: Select all

#include <zombie_escape>
 
// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
 
// Default Values
new const szZombieMadnessSound[][] =
{
    "zombie_escape/zombie_madness1.wav"
}
 
// Sound Max Length
#define SOUND_MAX_LENGTH 64
 
// Dynamic Array to Store our sound in
new Array:g_szZombie_Madness_Sound
 
// Task IDs
#define TASK_MADNESS 100
#define TASK_AURA 200
#define ID_MADNESS (taskid - TASK_MADNESS)
#define ID_AURA (taskid - TASK_AURA)
 
// Variables
new g_iItemID, bool:g_bZombieInMadness[33] , g_madnesscounter[33]
 
// Cvars
new Cvar_Madness_Time, Cvar_Madness_Aura_Red, Cvar_Madness_Aura_Green, Cvar_Madness_Aura_Blue , Cvar_Madness_limit
 
public plugin_init()
{
    register_plugin("[ZE] Items: Zombie Madness", ZE_VERSION, AUTHORS)
    register_event("HLTV", "New_Round", "a", "1=0", "2=0")
   
    // Hook Chains
    RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
    RegisterHookChain(RG_CBasePlayer_Spawn, "Fw_PlayerSpawn_Post", 1)
    RegisterHookChain(RG_CBasePlayer_Killed, "Fw_PlayerKilled_Post", 1)
   
    // Register our item
    g_iItemID = ze_register_item("Zombie Madness", 15)
   
    // Cvars
    Cvar_Madness_Time = register_cvar("ze_madness_time", "5.0")
    Cvar_Madness_Aura_Red = register_cvar("ze_madness_color_red", "255")
    Cvar_Madness_Aura_Green = register_cvar("ze_madness_color_green", "0")
    Cvar_Madness_Aura_Blue = register_cvar("ze_madness_color_blue", "0")
    Cvar_Madness_limit = register_cvar("ze_madness_limit", "2")
}
 
public New_Round()
{
	for(new id = 0; id < get_maxplayers(); id++)
	{
		g_madnesscounter[id] = 0
	}
}

public plugin_precache()
{
    // Initialize arrays
    g_szZombie_Madness_Sound = ArrayCreate(SOUND_MAX_LENGTH, 1)
   
    // Load from external file
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "ZOMBIE MADNESS", g_szZombie_Madness_Sound)
   
    // If we couldn't load custom sounds from file, use and save default ones
   
    new iIndex
   
    if (ArraySize(g_szZombie_Madness_Sound) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szZombieMadnessSound; iIndex++)
            ArrayPushString(g_szZombie_Madness_Sound, szZombieMadnessSound[iIndex])
       
        // Save to external file
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "ZOMBIE MADNESS", g_szZombie_Madness_Sound)
    }
   
    // Precache sounds
    new szSound[SOUND_MAX_LENGTH]
    for (iIndex = 0; iIndex < ArraySize(g_szZombie_Madness_Sound); iIndex++)
    {
        ArrayGetString(g_szZombie_Madness_Sound, iIndex, szSound, charsmax(szSound))
        precache_sound(szSound)
    }
}
 
public plugin_natives()
{
    register_native("ze_zombie_in_madness", "native_ze_zombie_in_madness")
}
 
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
   
    // Zombie madness only available to zombies
    if (!ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    // Player already has madness
    if (g_bZombieInMadness[id] || g_madnesscounter[id] > get_pcvar_num(Cvar_Madness_limit))
        return ZE_ITEM_UNAVAILABLE
   
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    // This is not our item, Block it here
    if (itemid != g_iItemID)
        return
       
    // Increase madness purchase count for this round
    g_madnesscounter[id]++
   
    // Player In Madness
    g_bZombieInMadness[id] = true
   
    // Madness aura
    set_task(0.1, "Madness_Aura", id+TASK_AURA, _, _, "b")
   
    // Madness sound
    new szSound[SOUND_MAX_LENGTH]
    ArrayGetString(g_szZombie_Madness_Sound, random_num(0, ArraySize(g_szZombie_Madness_Sound) - 1), szSound, charsmax(szSound))
    emit_sound(id, CHAN_VOICE, szSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
   
    // Set task to remove it
    set_task(get_pcvar_float(Cvar_Madness_Time), "Remove_Zombie_Madness", id+TASK_MADNESS)
}
 
// Player Spawn
public Fw_PlayerSpawn_Post(id)
{
    // Not alive or didn't join a team yet
    if (!is_user_alive(id) || !get_member(id, m_iTeam))
        return
   
    // Remove zombie madness from a previous round
    remove_task(id+TASK_MADNESS)
    remove_task(id+TASK_AURA)
    g_bZombieInMadness[id] = false
}
 
// Trace Attack
public Fw_TraceAttack_Pre(iVictim, iAttacker)
{
    // Allow Player to damage himself or Die From map bombs
    if (iVictim == iAttacker || !is_user_alive(iAttacker))
        return HC_CONTINUE
   
    // Prevent attacks when victim has zombie madness
    if (g_bZombieInMadness[iVictim])
        return HC_SUPERCEDE
   
    return HC_CONTINUE
}
 
public ze_frost_pre(id)
{
    // Prevent frost when victim has zombie madness
    if (g_bZombieInMadness[id])
        return PLUGIN_HANDLED
   
    return PLUGIN_CONTINUE
}
 
public ze_fire_pre(id)
{
    // Prevent burning when victim has zombie madness
    if (g_bZombieInMadness[id])
        return PLUGIN_HANDLED
   
    return PLUGIN_CONTINUE
}
 
public ze_user_humanized(id)
{
    // Remove zombie madness task if player somehow became human while he still in madness
    remove_task(id+TASK_MADNESS)
    remove_task(id+TASK_AURA)
    g_bZombieInMadness[id] = false
}
 
// Player Killed
public Fw_PlayerKilled_Post(iVictim)
{
    // Remove zombie madness task
    remove_task(iVictim+TASK_MADNESS)
    remove_task(iVictim+TASK_AURA)
    g_bZombieInMadness[iVictim] = false
}
 
// Remove Madness
public Remove_Zombie_Madness(taskid)
{
    // Remove aura
    remove_task(ID_MADNESS+TASK_AURA)
 
    // Remove zombie madness
    g_bZombieInMadness[ID_MADNESS] = false
}
 
public client_disconnect(id)
{
    // Remove tasks on disconnect
    remove_task(id+TASK_MADNESS)
    remove_task(id+TASK_AURA)
    g_bZombieInMadness[id] = false
    g_madnesscounter[id] = 0
}
 
// Madness aura task
public Madness_Aura(taskid)
{
    // Get player's origin
    static origin[3]
    get_user_origin(ID_AURA, origin)
   
    // Colored Aura
    message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
    write_byte(TE_DLIGHT) // TE id
    write_coord(origin[0]) // x
    write_coord(origin[1]) // y
    write_coord(origin[2]) // z
    write_byte(20) // radius
    write_byte(get_pcvar_num(Cvar_Madness_Aura_Red)) // r
    write_byte(get_pcvar_num(Cvar_Madness_Aura_Green)) // g
    write_byte(get_pcvar_num(Cvar_Madness_Aura_Blue)) // b
    write_byte(2) // life
    write_byte(0) // decay rate
    message_end()
}
 
public native_ze_zombie_in_madness(id)
{
    if (!is_user_alive(id))
    {
        // Throw Error and return false if player isn't alive
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    return g_bZombieInMadness[id]
}
 
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#4

Post by johnnysins2000 » 2 Years Ago

OK Problem Solved. Thnx Jack

But I need someone to Answer the Question about making limit for any zombie extra item
Nobody Is That Busy If They Make Time :roll:

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:

#5

Post by Raheem » 2 Years Ago

If you need to make limit for every player so we will make an array for every player, So first step:

new g_iLimit[33]

Next step will be use this array in our functions so let's take simple example i'll add limit for Fire Nade extra-item, The code before editing anything:
    1. #include <zombie_escape>
    2.  
    3. // Default Sound
    4. new const g_szBuyAmmoSound[] = "items/9mmclip1.wav"
    5.  
    6. // Variables
    7. new g_iItemID
    8.  
    9. public plugin_init()
    10. {
    11.     register_plugin("[ZE] Items: Fire Nade", ZE_VERSION, AUTHORS)
    12.    
    13.     // Register our item
    14.     g_iItemID = ze_register_item("Fire Nade", 10)
    15. }
    16.  
    17. public ze_select_item_pre(id, itemid)
    18. {
    19.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    20.     if (itemid != g_iItemID)
    21.         return ZE_ITEM_AVAILABLE
    22.    
    23.     // Available for Humans only, So don't show it for zombies
    24.     if (ze_is_user_zombie(id))
    25.         return ZE_ITEM_DONT_SHOW
    26.    
    27.     return ZE_ITEM_AVAILABLE
    28. }
    29.  
    30. public ze_select_item_post(id, itemid)
    31. {
    32.     // This is not our item, Block it here
    33.     if (itemid != g_iItemID)
    34.         return
    35.    
    36.     // Get Weapon ID
    37.     new iWpnID = get_weaponid("weapon_hegrenade")
    38.    
    39.     // Player Don't have Frost Grenade then give him
    40.     if (rg_get_user_bpammo(id, WeaponIdType:iWpnID) == 0)
    41.     {
    42.         rg_give_item(id, "weapon_hegrenade", GT_APPEND)
    43.     }
    44.     else
    45.     {
    46.         // Player have, Increase his Back Pack Ammo, And play buy BP sound + Hud Flash
    47.         rg_set_user_bpammo(id, WeaponIdType:iWpnID, rg_get_user_bpammo(id, WeaponIdType:iWpnID) + 1)
    48.         emit_sound(id, CHAN_ITEM, g_szBuyAmmoSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    49.         Show_Given_BPAmmo(id, 12, 1) // HE Grenade AmmoType Const = 12
    50.     }
    51. }
After adding limit:
    1. #include <zombie_escape>
    2.  
    3. // Default Sound
    4. new const g_szBuyAmmoSound[] = "items/9mmclip1.wav"
    5.  
    6. // Defines
    7. #define LIMIT 3
    8.  
    9. // Variables
    10. new g_iItemID, g_iLimit[33]
    11.  
    12. public plugin_init()
    13. {
    14.     register_plugin("[ZE] Items: Fire Nade", ZE_VERSION, AUTHORS)
    15.    
    16.     // Register our item
    17.     g_iItemID = ze_register_item("Fire Nade", 10)
    18. }
    19.  
    20. public ze_select_item_pre(id, itemid)
    21. {
    22.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    23.     if (itemid != g_iItemID)
    24.         return ZE_ITEM_AVAILABLE
    25.    
    26.     // Available for Humans only, So don't show it for zombies
    27.     if (ze_is_user_zombie(id))
    28.         return ZE_ITEM_DONT_SHOW
    29.    
    30.     // If he bought it more than 3 so return that it's not Available
    31.     if (g_iLimit[id] >= LIMIT)
    32.         return ZE_ITEM_UNAVAILABLE
    33.    
    34.     return ZE_ITEM_AVAILABLE
    35. }
    36.  
    37. public ze_select_item_post(id, itemid)
    38. {
    39.     // This is not our item, Block it here
    40.     if (itemid != g_iItemID)
    41.         return
    42.    
    43.     // Get Weapon ID
    44.     new iWpnID = get_weaponid("weapon_hegrenade")
    45.    
    46.     // Player Don't have Frost Grenade then give him
    47.     if (rg_get_user_bpammo(id, WeaponIdType:iWpnID) == 0)
    48.     {
    49.         rg_give_item(id, "weapon_hegrenade", GT_APPEND)
    50.         g_iLimit[id]++ // Mean g_iLimit[id] = g_iLimit[id] + 1
    51.     }
    52.     else
    53.     {
    54.         // Player have, Increase his Back Pack Ammo, And play buy BP sound + Hud Flash
    55.         rg_set_user_bpammo(id, WeaponIdType:iWpnID, rg_get_user_bpammo(id, WeaponIdType:iWpnID) + 1)
    56.         emit_sound(id, CHAN_ITEM, g_szBuyAmmoSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    57.         Show_Given_BPAmmo(id, 12, 1) // HE Grenade AmmoType Const = 12
    58.         g_iLimit[id]++ // Mean g_iLimit[id] = g_iLimit[id] + 1
    59.     }
    60. }
You can instead of define the limit make cvar for it if you need so it will be like:
    1. #include <zombie_escape>
    2.  
    3. // Default Sound
    4. new const g_szBuyAmmoSound[] = "items/9mmclip1.wav"
    5.  
    6. // Variables
    7. new g_iItemID, g_iLimit[33]
    8.  
    9. // Cvars
    10. new cvar_limit
    11.  
    12. public plugin_init()
    13. {
    14.     register_plugin("[ZE] Items: Fire Nade", ZE_VERSION, AUTHORS)
    15.    
    16.     // Register our item
    17.     g_iItemID = ze_register_item("Fire Nade", 10)
    18.    
    19.     // Cvars
    20.     cvar_limit = register_cvar("ze_fire_nade_limit", "3")
    21. }
    22.  
    23. public ze_select_item_pre(id, itemid)
    24. {
    25.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    26.     if (itemid != g_iItemID)
    27.         return ZE_ITEM_AVAILABLE
    28.    
    29.     // Available for Humans only, So don't show it for zombies
    30.     if (ze_is_user_zombie(id))
    31.         return ZE_ITEM_DONT_SHOW
    32.    
    33.     // If he bought it more than 3 so return that it's not Available
    34.     if (g_iLimit[id] >= get_pcvar_num(cvar_limit))
    35.         return ZE_ITEM_UNAVAILABLE
    36.    
    37.     return ZE_ITEM_AVAILABLE
    38. }
    39.  
    40. public ze_select_item_post(id, itemid)
    41. {
    42.     // This is not our item, Block it here
    43.     if (itemid != g_iItemID)
    44.         return
    45.    
    46.     // Get Weapon ID
    47.     new iWpnID = get_weaponid("weapon_hegrenade")
    48.    
    49.     // Player Don't have Frost Grenade then give him
    50.     if (rg_get_user_bpammo(id, WeaponIdType:iWpnID) == 0)
    51.     {
    52.         rg_give_item(id, "weapon_hegrenade", GT_APPEND)
    53.         g_iLimit[id]++ // Mean g_iLimit[id] = g_iLimit[id] + 1
    54.     }
    55.     else
    56.     {
    57.         // Player have, Increase his Back Pack Ammo, And play buy BP sound + Hud Flash
    58.         rg_set_user_bpammo(id, WeaponIdType:iWpnID, rg_get_user_bpammo(id, WeaponIdType:iWpnID) + 1)
    59.         emit_sound(id, CHAN_ITEM, g_szBuyAmmoSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    60.         Show_Given_BPAmmo(id, 12, 1) // HE Grenade AmmoType Const = 12
    61.         g_iLimit[id]++ // Mean g_iLimit[id] = g_iLimit[id] + 1
    62.     }
    63. }
Hope you get it :).
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#6

Post by johnnysins2000 » 2 Years Ago

OK bro thnx
Nobody Is That Busy If They Make Time :roll:

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests