[ZE] Extra Item : Immunity Convert

Unpaid Requests, Public Plugins
Post Reply
Mystic Viper
Member
Member
Romania
Posts: 87
Joined: 9 Months Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

[ZE] Extra Item : Immunity Convert

#1

Post by Mystic Viper » 2 Months Ago

Can someone convert this extra item?
  1. /*
  2. [ZP] Extra Item : Immunity
  3.  
  4. Plugin Thread :
  5.  
  6. http://forums.alliedmods.net/showthread.php?t=105537
  7. */
  8.  
  9.  
  10. #include <amxmodx>
  11. #include <fun>
  12. #include <hamsandwich>
  13. #include <zombieplague>
  14.  
  15. #define AUTHOR "Javivi & sunx"
  16.  
  17. // Bitsums
  18. #define HaveImmunity(%1) g_HaveImmunity & (1<<(%1 & 31))
  19. #define SetHaveImmunity(%1) g_HaveImmunity |= (1<<(%1 & 31))
  20. #define ClearHaveImmunity(%1) g_HaveImmunity &= ~(1<<(%1 & 31))
  21.  
  22.  
  23.  
  24. // If you want immunity for all round, uncomment this !
  25. //#define ALLROUND
  26.  
  27. // Task IDs
  28. #define TASK_AURA 321
  29.  
  30. // Ammo Pack cost
  31. #if !defined ALLROUND
  32. new const ITEM_COST = 15
  33. #else
  34. new const ITEM_COST = 30
  35. #endif
  36.  
  37. // Variables
  38. new g_itemID, g_HudSync, g_SayText, g_HaveImmunity
  39.  
  40. // Cvars
  41. #if !defined ALLROUND
  42. new cvar_duration
  43. #endif
  44.  
  45. new cvar_auracolor, cvar_aurasize
  46.  
  47. // Array
  48. new /*g_HaveImmunity[33],*/ Time[33]
  49.  
  50.  
  51. public plugin_init()
  52. {
  53.     // Plugin register
  54.     register_plugin("[ZP] Extra Item: Immunity", "3.0", AUTHOR)
  55.    
  56.     // Cvars
  57.     #if !defined ALLROUND
  58.     cvar_duration = register_cvar("zp_immunity_duration", "30")
  59.     #endif
  60.    
  61.     cvar_auracolor = register_cvar("zp_immunity_color", "255 165 0")
  62.     cvar_aurasize = register_cvar("zp_immunity_aura_size", "25")
  63.    
  64.     // Variables
  65.     #if !defined ALLROUND
  66.     g_itemID = zp_register_extra_item("Immunity", ITEM_COST , ZP_TEAM_HUMAN)   
  67.     #else
  68.     g_itemID = zp_register_extra_item("Immunity (All round)", ITEM_COST , ZP_TEAM_HUMAN)   
  69.     #endif
  70.     g_HudSync = CreateHudSyncObj()
  71.     g_SayText = get_user_msgid("SayText")
  72.    
  73.     // Language File
  74.     register_dictionary("zp_extra_immunity.txt")
  75.    
  76.     // Hamsandwich forward
  77.     RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  78.    
  79.     // Gamemonitor info
  80.     static szCvar[30]
  81.     formatex(szCvar, charsmax(szCvar), "v3.0 by Javivi")
  82.     register_cvar("zp_immunity", szCvar, FCVAR_SERVER|FCVAR_SPONLY)
  83. }
  84.  
  85. // If some one buy the item
  86. public zp_extra_item_selected(id, itemid)
  87. {
  88.     if(itemid == g_itemID)
  89.     {
  90.         // Wait until the round start
  91.         if (!zp_has_round_started())
  92.         {
  93.             new Temp[32]
  94.             formatex(Temp, 31 , "!g[ZP] !y%L", id, "WAIT")
  95.             chat_color(id, Temp)
  96.             zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + ITEM_COST)
  97.            
  98.             return
  99.         }
  100.         // If the player already have immunity
  101.         if(HaveImmunity(id))
  102.         {
  103.             new Temp[32]
  104.             formatex(Temp, 31, "!g[ZP] !y%L", id, "ALREADY")
  105.             chat_color(id, Temp)   
  106.             zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + ITEM_COST)
  107.            
  108.             return
  109.         }
  110.        
  111.         // If the player dont have immunity
  112.         else
  113.         {
  114.             // Enable Godmode
  115.             set_user_godmode(id, 1)
  116.            
  117.             // Aura task
  118.             set_task(0.1, "aura", id + TASK_AURA, _, _, "b")
  119.            
  120.             SetHaveImmunity(id)
  121.            
  122.             // If you want use the item all round
  123.             #if defined ALLROUND
  124.             set_hudmessage(85, 127, 255, -1.0, 0.15, 1, 0.1, 3.0, 0.05, 0.05, -1)
  125.             ShowSyncHudMsg(id, g_HudSync, "%L", id, "IMMUME")
  126.            
  127.             #else
  128.             // Start the countdown !
  129.             Time[id] = get_pcvar_num(cvar_duration)
  130.             CountDown(id)
  131.            
  132.             #endif
  133.         }
  134.        
  135.     }
  136. }
  137.  
  138. // Countdown code
  139. public CountDown(id)
  140. {
  141.     // If time is 0 or -1
  142.     if(Time[id] <= 0)
  143.     {      
  144.         // Remove aura task
  145.         remove_task(id + TASK_AURA)
  146.        
  147.         // Client_Print
  148.         client_print(id, print_center, "%L", id, "EXPIRED")
  149.        
  150.         // Disable godmode
  151.         set_user_godmode(id, 0)
  152.        
  153.         // Remove immunity
  154.         ClearHaveImmunity(id)
  155.        
  156.         // Remove countdown
  157.         return
  158.     }
  159.    
  160.     // Time - 1
  161.     Time[id]--
  162.    
  163.     // Show the immunity seconds
  164.     set_hudmessage(85, 127, 255, -1.0, 0.15, 1, 0.1, 3.0, 0.05, 0.05, -1)
  165.     ShowSyncHudMsg(id, g_HudSync, "%L", id, "REMAINING", Time[id])
  166.    
  167.     // Repeat
  168.     set_task(1.0, "CountDown", id)
  169. }
  170.  
  171.  
  172.  
  173. // If user is infected (Infection nade)
  174. public zp_user_infected_post(id)
  175. {
  176.     if(HaveImmunity(id))
  177.     {
  178.         #if !defined ALLROUND
  179.         // Remove countdown task
  180.         Time[id] = 0
  181.         #endif
  182.        
  183.         // Remove aura task
  184.         remove_task(id + TASK_AURA)
  185.        
  186.         // Remove immunity
  187.         ClearHaveImmunity(id)
  188.        
  189.         // Disable godmode
  190.         set_user_godmode(id, 0)
  191.     }
  192. }
  193.  
  194.  
  195. // At player spawn
  196. public fw_PlayerSpawn_Post(id)
  197. {
  198.     if(HaveImmunity(id))
  199.     {
  200.         #if !defined ALLROUND
  201.         // Remove countdown task
  202.         Time[id] = 0
  203.        
  204.         #else
  205.        
  206.         // If allround is uncommented show a message.
  207.         client_print(id, print_center, "%L", id, "EXPIRED")
  208.         #endif
  209.        
  210.         // Remove aura task
  211.         remove_task(id + TASK_AURA)
  212.        
  213.         // Disable godmode
  214.         set_user_godmode(id, 0)
  215.        
  216.         // Remove immunity
  217.         ClearHaveImmunity(id)
  218.     }
  219. }
  220.  
  221.  
  222.  
  223. /*============
  224. Aura Code
  225. ============*/
  226.  
  227. public aura(id)
  228. {
  229.     id -= TASK_AURA
  230.    
  231.    
  232.     // If user die
  233.     if (!is_user_alive(id))
  234.         return
  235.    
  236.     // Color cvar ---> RGB!
  237.     new szColors[16]
  238.     get_pcvar_string(cvar_auracolor, szColors, 15)
  239.    
  240.     new gRed[4], gGreen[4], gBlue[4], iRed, iGreen, iBlue
  241.     parse(szColors, gRed, 3, gGreen, 3, gBlue, 3)
  242.    
  243.     iRed = clamp(str_to_num(gRed), 0, 255)
  244.     iGreen = clamp(str_to_num(gGreen), 0, 255)
  245.     iBlue = clamp(str_to_num(gBlue), 0, 255)
  246.    
  247.     new Origin[3]
  248.     get_user_origin(id, Origin)
  249.    
  250.     message_begin(MSG_ALL, SVC_TEMPENTITY)
  251.     write_byte(TE_DLIGHT)
  252.     write_coord(Origin[0])
  253.     write_coord(Origin[1])
  254.     write_coord(Origin[2])
  255.     write_byte(get_pcvar_num(cvar_aurasize))
  256.     write_byte(iRed) //   R
  257.     write_byte(iGreen) // G
  258.     write_byte(iBlue) //  B
  259.     write_byte(2)
  260.     write_byte(0)
  261.     message_end()
  262. }
  263.  
  264.  
  265. /*===============
  266. ColorChat Stock
  267. ===============*/
  268.  
  269. stock chat_color(const id, const input[], any:...)
  270. {
  271.     static msg[191]
  272.     vformat(msg, 190, input, 3)
  273.    
  274.     replace_all(msg, 190, "!g", "^4")
  275.     replace_all(msg, 190, "!y", "^1")
  276.     replace_all(msg, 190, "!t", "^3")
  277.    
  278.     message_begin(MSG_ONE_UNRELIABLE, g_SayText, _, id)
  279.     write_byte(id)
  280.     write_string(msg)
  281.     message_end()
  282. }

karan
Mod Tester
Mod Tester
India
Posts: 50
Joined: 1 Year Ago
Location: India
Has thanked: 1 time
Been thanked: 3 times
Age: 21
Contact:

#2

Post by karan » 1 Month Ago

  1. /*
  2. [ZE] Extra Item : Immunity
  3.  
  4. Plugin Thread :
  5.  
  6. http://forums.alliedmods.net/showthread.php?t=105537
  7. */
  8.  
  9. #include <zombie_escape>
  10. #include <amxmodx>
  11. #include <fun>
  12. #include <hamsandwich>
  13.  
  14. #define AUTHOR "Javivi & sunx"
  15.  
  16. // Bitsums
  17. #define HaveImmunity(%1) g_HaveImmunity & (1<<(%1 & 31))
  18. #define SetHaveImmunity(%1) g_HaveImmunity |= (1<<(%1 & 31))
  19. #define ClearHaveImmunity(%1) g_HaveImmunity &= ~(1<<(%1 & 31))
  20.  
  21.  
  22.  
  23. // If you want immunity for all round, uncomment this !
  24. //#define ALLROUND
  25.  
  26. // Task IDs
  27. #define TASK_AURA 321
  28.  
  29. // Ammo Pack cost
  30. #if !defined ALLROUND
  31. new const ITEM_COST = 15
  32. #else
  33. new const ITEM_COST = 30
  34. #endif
  35.  
  36. // Variables
  37. new g_itemID, g_HudSync, g_SayText, g_HaveImmunity
  38.  
  39. // Cvars
  40. #if !defined ALLROUND
  41. new cvar_duration
  42. #endif
  43.  
  44. new cvar_auracolor, cvar_aurasize
  45.  
  46. // Array
  47. new /*g_HaveImmunity[33],*/ Time[33]
  48.  
  49.  
  50. public plugin_init()
  51. {
  52.     // Plugin register
  53.     register_plugin("[ZE] Extra Item: Immunity", "3.0", AUTHOR)
  54.    
  55.     // Cvars
  56.     #if !defined ALLROUND
  57.     cvar_duration = register_cvar("ze_immunity_duration", "30")
  58.     #endif
  59.    
  60.     cvar_auracolor = register_cvar("ze_immunity_color", "255 165 0")
  61.     cvar_aurasize = register_cvar("ze_immunity_aura_size", "25")
  62.    
  63.     // Variables
  64.     #if !defined ALLROUND
  65.     g_itemID = ze_register_item("Immunity", ITEM_COST , 0)  
  66.     #else
  67.     g_itemID = ze_register_item("Immunity (All round)", ITEM_COST , 0)  
  68.     #endif
  69.     g_HudSync = CreateHudSyncObj()
  70.     g_SayText = get_user_msgid("SayText")
  71.    
  72.     // Language File
  73.     register_dictionary("zp_extra_immunity.txt")
  74.    
  75.     // Hamsandwich forward
  76.     RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  77.    
  78.     // Gamemonitor info
  79.     static szCvar[30]
  80.     formatex(szCvar, charsmax(szCvar), "v3.0 by Javivi")
  81.     register_cvar("ze_immunity", szCvar, FCVAR_SERVER|FCVAR_SPONLY)
  82. }
  83.  
  84. public ze_select_item_pre(id, itemid)
  85. {
  86.     // This not our item?
  87.     if (itemid != g_itemID)
  88.         return ZE_ITEM_AVAILABLE
  89.    
  90.     // Available for Humans only, So don't show it for zombies
  91.     if (ze_is_user_zombie(id))
  92.         return ZE_ITEM_DONT_SHOW
  93.    
  94.     // Finally return that it's available
  95.     return ZE_ITEM_AVAILABLE
  96. }
  97.  
  98. // If some one buy the item
  99. public ze_select_item_post(id, itemid)
  100. {
  101.     if(itemid == g_itemID)
  102.     {
  103.         // Wait until the round start
  104.         if (!ze_is_game_started())
  105.         {
  106.             new Temp[32]
  107.             formatex(Temp, 31 , "!g[ZE] !y%L", id, "WAIT")
  108.             chat_color(id, Temp)
  109.             ze_set_escape_coins(id, ze_get_escape_coins(id) + ITEM_COST)
  110.            
  111.             return
  112.         }
  113.         // If the player already have immunity
  114.         if(HaveImmunity(id))
  115.         {
  116.             new Temp[32]
  117.             formatex(Temp, 31, "!g[ZE] !y%L", id, "ALREADY")
  118.             chat_color(id, Temp)  
  119.             ze_set_escape_coins(id, ze_get_escape_coins(id) + ITEM_COST)
  120.            
  121.             return
  122.         }
  123.        
  124.         // If the player dont have immunity
  125.         else
  126.         {
  127.             // Enable Godmode
  128.             set_user_godmode(id, 1)
  129.            
  130.             // Aura task
  131.             set_task(0.1, "aura", id + TASK_AURA, _, _, "b")
  132.            
  133.             SetHaveImmunity(id)
  134.            
  135.             // If you want use the item all round
  136.             #if defined ALLROUND
  137.             set_hudmessage(85, 127, 255, -1.0, 0.15, 1, 0.1, 3.0, 0.05, 0.05, -1)
  138.             ShowSyncHudMsg(id, g_HudSync, "%L", id, "IMMUME")
  139.            
  140.             #else
  141.             // Start the countdown !
  142.             Time[id] = get_pcvar_num(cvar_duration)
  143.             CountDown(id)
  144.            
  145.             #endif
  146.         }
  147.        
  148.     }
  149. }
  150.  
  151. // Countdown code
  152. public CountDown(id)
  153. {
  154.     // If time is 0 or -1
  155.     if(Time[id] <= 0)
  156.     {      
  157.         // Remove aura task
  158.         remove_task(id + TASK_AURA)
  159.        
  160.         // Client_Print
  161.         client_print(id, print_center, "%L", id, "EXPIRED")
  162.        
  163.         // Disable godmode
  164.         set_user_godmode(id, 0)
  165.        
  166.         // Remove immunity
  167.         ClearHaveImmunity(id)
  168.        
  169.         // Remove countdown
  170.         return
  171.     }
  172.    
  173.     // Time - 1
  174.     Time[id]--
  175.    
  176.     // Show the immunity seconds
  177.     set_hudmessage(85, 127, 255, -1.0, 0.15, 1, 0.1, 3.0, 0.05, 0.05, -1)
  178.     ShowSyncHudMsg(id, g_HudSync, "%L", id, "REMAINING", Time[id])
  179.    
  180.     // Repeat
  181.     set_task(1.0, "CountDown", id)
  182. }
  183.  
  184.  
  185.  
  186. // If user is infected (Infection nade)
  187. public ze_user_infected(id)
  188. {
  189.     if(HaveImmunity(id))
  190.     {
  191.         #if !defined ALLROUND
  192.         // Remove countdown task
  193.         Time[id] = 0
  194.         #endif
  195.        
  196.         // Remove aura task
  197.         remove_task(id + TASK_AURA)
  198.        
  199.         // Remove immunity
  200.         ClearHaveImmunity(id)
  201.        
  202.         // Disable godmode
  203.         set_user_godmode(id, 0)
  204.     }
  205. }
  206.  
  207.  
  208. // At player spawn
  209. public fw_PlayerSpawn_Post(id)
  210. {
  211.     if(HaveImmunity(id))
  212.     {
  213.         #if !defined ALLROUND
  214.         // Remove countdown task
  215.         Time[id] = 0
  216.        
  217.         #else
  218.        
  219.         // If allround is uncommented show a message.
  220.         client_print(id, print_center, "%L", id, "EXPIRED")
  221.         #endif
  222.        
  223.         // Remove aura task
  224.         remove_task(id + TASK_AURA)
  225.        
  226.         // Disable godmode
  227.         set_user_godmode(id, 0)
  228.        
  229.         // Remove immunity
  230.         ClearHaveImmunity(id)
  231.     }
  232. }
  233.  
  234.  
  235.  
  236. /*============
  237. Aura Code
  238. ============*/
  239.  
  240. public aura(id)
  241. {
  242.     id -= TASK_AURA
  243.    
  244.    
  245.     // If user die
  246.     if (!is_user_alive(id))
  247.         return
  248.    
  249.     // Color cvar ---> RGB!
  250.     new szColors[16]
  251.     get_pcvar_string(cvar_auracolor, szColors, 15)
  252.    
  253.     new gRed[4], gGreen[4], gBlue[4], iRed, iGreen, iBlue
  254.     parse(szColors, gRed, 3, gGreen, 3, gBlue, 3)
  255.    
  256.     iRed = clamp(str_to_num(gRed), 0, 255)
  257.     iGreen = clamp(str_to_num(gGreen), 0, 255)
  258.     iBlue = clamp(str_to_num(gBlue), 0, 255)
  259.    
  260.     new Origin[3]
  261.     get_user_origin(id, Origin)
  262.    
  263.     message_begin(MSG_ALL, SVC_TEMPENTITY)
  264.     write_byte(TE_DLIGHT)
  265.     write_coord(Origin[0])
  266.     write_coord(Origin[1])
  267.     write_coord(Origin[2])
  268.     write_byte(get_pcvar_num(cvar_aurasize))
  269.     write_byte(iRed) //   R
  270.     write_byte(iGreen) // G
  271.     write_byte(iBlue) //  B
  272.     write_byte(2)
  273.     write_byte(0)
  274.     message_end()
  275. }
  276.  
  277.  
  278. /*===============
  279. ColorChat Stock
  280. ===============*/
  281.  
  282. stock chat_color(const id, const input[], any:...)
  283. {
  284.     static msg[191]
  285.     vformat(msg, 190, input, 3)
  286.    
  287.     replace_all(msg, 190, "!g", "^4")
  288.     replace_all(msg, 190, "!y", "^1")
  289.     replace_all(msg, 190, "!t", "^3")
  290.    
  291.     message_begin(MSG_ONE_UNRELIABLE, g_SayText, _, id)
  292.     write_byte(id)
  293.     write_string(msg)
  294.     message_end()
  295. }
NeVeR DiE | Zombie Escape
IP : 139.59.90.127:40000
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests