Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. #include <engine>
  5. #include <fakemeta>
  6. #include <fun>
  7. #include <ColorChat>
  8. #include <codmod>
  9.  
  10. #define MIN 1
  11. #define MAX 6
  12.  
  13. new const chatPrefix[] = "^x04[^x01PACK^x04]^x01";
  14.  
  15. new const itemModel[] = "models/cod_paczka.mdl";
  16.  
  17. new const healthValues[] =
  18. {
  19. 10,
  20. 20,
  21. 30,
  22. 40,
  23. 50
  24. }
  25.  
  26. new const coinsValues[] =
  27. {
  28. 21,
  29. 42,
  30. 53,
  31. 64,
  32. 75
  33. }
  34.  
  35. new const expValues[] =
  36. {
  37. 144,
  38. 244,
  39. 344,
  40. 444,
  41. 544
  42. }
  43.  
  44. public plugin_init()
  45. {
  46. register_plugin("COD: Pack Bonuses", "1.0", "radim");
  47.  
  48. register_event("DeathMsg", "deathMessage", "a");
  49. register_logevent("roundStart", 2, "1=Round_Start");
  50. }
  51.  
  52. public plugin_precache()
  53. {
  54. precache_model(itemModel);
  55. }
  56.  
  57. public roundStart()
  58. {
  59. kill_all_entity("packes");
  60. }
  61.  
  62. public deathMessage()
  63. {
  64. new killer = read_data(1),
  65. victim = read_data(2);
  66.  
  67. if(killer == victim || !is_user_connected(killer) || !is_user_connected(victim))
  68. {
  69. return PLUGIN_CONTINUE;
  70. }
  71.  
  72. create_itm(victim, 0);
  73.  
  74. return PLUGIN_CONTINUE;
  75. }
  76.  
  77. public usePackes(index)
  78. {
  79. if(!is_user_alive(index))
  80. {
  81. return PLUGIN_HANDLED;
  82. }
  83.  
  84. new randomCase = random_num(MIN, MAX);
  85.  
  86. switch(randomCase)
  87. {
  88. case 1:
  89. {
  90. new randomHealth = healthValues[random_num(0, sizeof(healthValues) - 1)];
  91.  
  92. set_user_health(index, get_user_health(index) - randomHealth);
  93.  
  94. ColorChat(index, NORMAL, "%sZnalazles trucizne.. Tracisz %i HP", chatPrefix, randomHealth);
  95. }
  96. case 2:
  97. {
  98. new randomHealth = healthValues[random_num(0, sizeof(healthValues) - 1)];
  99.  
  100. set_user_health(index, get_user_health(index) + randomHealth);
  101.  
  102. ColorChat(index, NORMAL, "Znalazles apteczke.. Dostajesz %i HP", chatPrefix, randomHealth);
  103. }
  104. case 3:
  105. {
  106. new randomCoins = coinsValues[random_num(0, sizeof(coinsValues) - 1)];
  107.  
  108. cod_set_user_coins(index, cod_get_user_coins(index) + randomCoins);
  109.  
  110. ColorChat(index, NORMAL, "W paczce znalazles kilka monet (%i)", chatPrefix, randomCoins)
  111. }
  112. case 4:
  113. {
  114. new randomCoins = coinsValues[random_num(0, sizeof(coinsValues) - 1)];
  115.  
  116. if(cod_get_user_coins(index) - randomCoins < 0)
  117. {
  118. ColorChat(index, NORMAL, "Ktos probowal cie okrasc, ale nie masz hajsu ;-;", chatPrefix);
  119. return PLUGIN_HANDLED
  120. }
  121.  
  122. cod_set_user_coins(index, cod_get_user_coins(index) - randomCoins);
  123.  
  124. ColorChat(index, NORMAL, "Ktos Cie okradl z %i monet :O", chatPrefix, randomCoins)
  125. }
  126. case 5:
  127. {
  128. new randomExp = expValues[random_num(0, sizeof(expValues) - 1)]
  129.  
  130. if(cod_get_user_xp(index) - randomExp < 0)
  131. {
  132. ColorChat(index, NORMAL, "... %i", chatPrefix, randomExp);
  133. return PLUGIN_HANDLED
  134. }
  135. }
  136. case 6:
  137. {
  138. new randomExp = expValues[random_num(0, sizeof(expValues) - 1)]
  139.  
  140. cod_set_user_xp(index, cod_get_user_xp(index) + randomExp);
  141.  
  142. ColorChat(index, NORMAL, "W paczce znalazles dodatkowe %i EXP'a!", chatPrefix, randomExp);
  143. }
  144. }
  145. return PLUGIN_HANDLED;
  146. }
  147.  
  148. public create_itm(index, index_item)
  149. {
  150. new Float:origins[3],
  151. entit = create_entity("info_target");
  152.  
  153. pev(index, pev_origin, origins);
  154.  
  155. origins[0] += 50.0;
  156. origins[2] -= 32.0;
  157.  
  158. set_pev(entit, pev_origin, origins);
  159.  
  160. entity_set_model(entit, itemModel);
  161.  
  162. set_pev(entit, pev_classname, "paczka");
  163.  
  164. dllfunc(DLLFunc_Spawn, entit);
  165.  
  166. set_pev(entit, pev_solid, SOLID_BBOX);
  167. set_pev(entit, pev_movetype, MOVETYPE_FLY);
  168.  
  169. engfunc(EngFunc_SetSize, entit,
  170. {-1.1, -1.1, -1.1},
  171. {1.1, 1.1, 1.1}
  172. );
  173.  
  174. engfunc(EngFunc_DropToFloor, entit);
  175.  
  176. set_pev(entit, pev_iuser1, index_item);
  177.  
  178. }
  179.  
  180. public fwd_touch(ent, index)
  181. {
  182. static classname[32];
  183. pev(ent, pev_classname, classname, charsmax(classname));
  184.  
  185. if(!is_user_alive(index))
  186. {
  187. return FMRES_IGNORED;
  188. }
  189. if(!pev_valid(ent))
  190. {
  191. return FMRES_IGNORED;
  192. }
  193. if(!equali(classname, "packes"))
  194. {
  195. return FMRES_IGNORED;
  196. }
  197. if(pev(index, pev_button))
  198. {
  199. usePackes(index);
  200. engfunc(EngFunc_RemoveEntity, ent);
  201. }
  202. return FMRES_IGNORED;
  203. }
  204.  
  205. public kill_all_entity(classname[])
  206. {
  207. new iEnt = find_ent_by_class(-1, classname)
  208. while(iEnt > 0)
  209. {
  210. remove_entity(iEnt)
  211. iEnt = find_ent_by_class(iEnt, classname);
  212. }
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement