Advertisement
Guest User

Untitled

a guest
Mar 17th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5.  
  6. #define PLUGIN "Graffiti"
  7. #define VERSION "1.0"
  8. #define AUTHOR "Ark'xes"
  9.  
  10.  
  11. new bool:graffitiCooldown[33];
  12. new UserGraffiti[64][33];
  13. new GraffitiBox[33];
  14. new SelectedGraffiti[33];
  15. new cvar_RemoveGraffiti;
  16. new cvar_GraffitiCD;
  17.  
  18.  
  19. public plugin_precache()
  20. {
  21. precache_model("models/csgo_graffit.mdl");
  22. }
  23. public plugin_init() {
  24. register_plugin(PLUGIN, VERSION, AUTHOR)
  25. register_clcmd("say /graff", "GraffitiMenu")
  26. register_impulse(201, "Graffiti");
  27. register_cvar("go_removegraffiti", 4115128, MaxClients, MaxClients);
  28. register_cvar("go_graffiticd", "30.0", MaxClients, MaxClients);
  29.  
  30. public client_impulse(id, impulse)
  31. {
  32. if (impulse == 201)
  33. {
  34. return 1;
  35. }
  36. return 0;
  37. }
  38.  
  39. public removeGraffiti()
  40. {
  41. new ent = -1;
  42. while ((ent = find_ent_by_class(ent, "GraffitiEntity")))
  43. {
  44. remove_entity(ent);
  45. }
  46. return 0;
  47. }
  48.  
  49. public removeEntity(id)
  50. {
  51. new ent = -1;
  52. while ((ent = find_ent_by_owner(ent, "ThinkingEntity", id, MaxClients)))
  53. {
  54. remove_entity(ent);
  55. }
  56. return 0;
  57. }
  58. public Graffiti(id)
  59. {
  60. new ent = create_entity("info_target");
  61. new Float:fAimOrigin[3] = 0.0;
  62. new Float:fPlayerOrigin[3] = 0.0;
  63. new Float:fAimVector[3] = 0.0;
  64. new Float:fNormalVector[3] = 0.0;
  65. new Float:fTextVector[3] = 0.0;
  66. new Float:fraction = 0.0;
  67. pev(id, 126, fAimVector);
  68. angle_vector(fAimVector, 1, fAimVector);
  69. pev(id, 118, fPlayerOrigin);
  70. fAimVector[0] = floatadd(floatmul(1176255488, fAimVector[0]), fPlayerOrigin[0]);
  71. fAimVector[1] = floatadd(floatmul(1176255488, fAimVector[1]), fPlayerOrigin[1]);
  72. fAimVector[2] = floatadd(1148846080, floatadd(floatmul(1176255488, fAimVector[2]), fPlayerOrigin[2]));
  73. new iTr = create_tr2();
  74. engfunc(29, fPlayerOrigin, fAimVector, 1, id, iTr);
  75. get_tr2(iTr, 5, fAimOrigin);
  76. get_tr2(iTr, 7, fNormalVector);
  77. get_tr2(iTr, NULL_STRING, fraction);
  78. free_tr2(iTr);
  79. new Float:mins[3] = {1.1776383E-38,8.167E-42,5.767E-41};
  80. new Float:maxs[3] = {7.987E-42,7.987E-42,5.7491E-41};
  81. new var1;
  82. if (fraction <= 0.01 && !graffitiCooldown[id])
  83. {
  84. if (SelectedGraffiti[id])
  85. {
  86. new Float:cooldown = get_pcvar_float(cvar_GraffitiCD);
  87. client_cmd(id, "spk %s", g_szSoundFileSpray);
  88. graffitiCooldown[id] = 1;
  89. set_task(cooldown, "RemoveCooldown", id, 4109032, MaxClients, 4109036, MaxClients);
  90. vector_to_angle(fNormalVector, fTextVector);
  91. entity_set_vector(ent, 6, fTextVector);
  92. entity_set_model(ent, "models/csgo_graffit.mdl");
  93. entity_set_size(ent, mins, maxs);
  94. entity_set_origin(ent, fAimOrigin);
  95. set_pev(ent, 133, 4122940);
  96. entity_set_int(ent, 14, MaxClients);
  97. entity_set_edict(ent, NULL_STRING, id);
  98. entity_set_string(ent, MaxClients, "GraffitiEntity");
  99. entity_set_int(ent, 15, MaxClients);
  100. set_pev(ent, 71, SelectedGraffiti[id] - 1);
  101. }
  102. client_print(id, NULL_STRING, "%L", id, "NO_GRAFFITI");
  103. }
  104. return 0;
  105. }
  106.  
  107. public RemoveCooldown(id)
  108. {
  109. graffitiCooldown[id] = 0;
  110. return 0;
  111. }
  112. public GraffitiMenu(id)
  113. {
  114. new szText[256];
  115. new String[32];
  116. formatex(szText, 256, "%L %L", id, "PREFIX_HUD", id, "MENU_GRAFFITI");
  117. new menu = menu_create(szText, "graffiti_handler", MaxClients);
  118. formatex(szText, 256, "%L\n\r------------------------", id, "OPEN_GRAFFITI", GraffitiBox[id]);
  119. menu_additem(menu, szText, "-1", MaxClients, -1);
  120. new i = 1;
  121. while (i < 64)
  122. {
  123. if (0 < UserGraffiti[i][id])
  124. {
  125. new var1;
  126. if (i == SelectedGraffiti[id])
  127. {
  128. var1 = 4141404;
  129. }
  130. else
  131. {
  132. var1 = 4141452;
  133. }
  134. formatex(szText, 256, "%s \w[\r%d\w] %L", Graffities[i], UserGraffiti[i][id], id, var1);
  135. formatex(String, 32, "%d", i);
  136. menu_additem(menu, szText, String, MaxClients, -1);
  137. }
  138. i++;
  139. }
  140. menu_setprop(menu, 6, 1);
  141. menu_display(id, menu, MaxClients, -1);
  142. return 1;
  143. }
  144.  
  145. public graffiti_handler(id, menu, item)
  146. {
  147. if (item == -3)
  148. {
  149. MainMenu(id);
  150. menu_destroy(menu);
  151. return 1;
  152. }
  153. new data[9];
  154. new name[64];
  155. new Key;
  156. new access;
  157. new callback;
  158. menu_item_getinfo(menu, item, access, data, NULL_VECTOR, name, 63, callback);
  159. Key = str_to_num(data);
  160. if (Key == -1)
  161. {
  162. if (0 < GraffitiBox[id])
  163. {
  164. new rNum = random_num(1, 63);
  165. client_print_color(id, MaxClients, "%L %L", id, "PREFIX_CHAT", id, "OPENED_GBOX", Graffities[rNum]);
  166. UserGraffiti[rNum][id]++;
  167. GraffitiBox[id]--;
  168. }
  169. GraffitiMenu(id);
  170. UpdateMisc(id);
  171. return 1;
  172. }
  173. if (Key == SelectedGraffiti[id])
  174. {
  175. SelectedGraffiti[id] = 0;
  176. }
  177. else
  178. {
  179. SelectedGraffiti[id] = Key;
  180. }
  181. GraffitiMenu(id);
  182. UpdateMisc(id);
  183. return 1;
  184. }
  185.  
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement