HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*******************************************************************************
  2.   AMX Paint Ball
  3.  
  4.  
  5.   Author: KRoTaL
  6.   Version: 0.5
  7.   - Ported to AMX MOD X by SAMURAI and Updated !
  8.  
  9.   0.1 Release
  10.   0.2 Optimization + added cvar paintball_randomcolor
  11.   0.3 Added cvar paintball_lifetime
  12.   0.4 Added pcvars
  13.   0.5 (10/02/2007) - Added a new cvar (read on Cvars part)
  14.  
  15.  
  16.   Cvars:
  17.  
  18.   paintball "1" - 0: disables the plugin
  19.   1: enables the plugin
  20.  
  21.   paintball_randomcolor "0" - 0: use defined colors
  22.   1: completely random colors
  23. NEW :
  24. 2: by team functions :
  25. players from CT Team will have blue colors
  26. players from T Team will have red colors
  27.  
  28.   paintball_maxballs "200" - how many balls (entities) on the map can be created by the plugin
  29.   decrease the value if your server crashes
  30.  
  31.   paintball_lifetime "10" - lifetime in seconds of the colored entities
  32.  
  33.  
  34.   Setup:
  35.  
  36.   Install the amxx file.
  37.   Enable Engine and Cstrike Module
  38.  
  39.  
  40. *******************************************************************************/
  41.  
  42. #include <amxmodx>
  43. #include <engine>
  44. #include <cstrike>
  45.  
  46. #define MAX_COLORS 9
  47.  
  48.  
  49. new g_paintSprite[2][] = {"sprites/bhit.spr", "sprites/richo1.spr"}
  50. new g_paintColors[MAX_COLORS][3] = {
  51. {255,255,255}, // white
  52. {255,0,0}, // red
  53. {0,255,0}, // green
  54. {0,0,255}, // blue
  55. {255,255,0}, // yellow
  56. {255,0,255}, // magenta
  57. {0,255,255}, // cyan
  58. {255,20,147}, // pink
  59. {255,165,0} // orange
  60. }
  61.  
  62. new lastwpn[33]
  63. new lastammo[33]
  64. new g_ballsnum = 0
  65.  
  66. // Cvars //
  67. new paintball
  68. new paintball_lifetime
  69. new paintball_randomcolor
  70. new paintball_maxballs
  71.  
  72.  
  73. public plugin_init()
  74. {
  75. register_plugin("Paint Ball", "0.5", "KRoTaL")
  76. paintball = register_cvar("paintball", "1")
  77. paintball_randomcolor = register_cvar("paintball_randomcolor", "0")
  78. paintball_maxballs = register_cvar("paintball_maxballs", "200")
  79. paintball_lifetime = register_cvar("paintball_lifetime", "10")
  80. register_event("CurWeapon", "make_paint", "be", "3>0")
  81. register_logevent("new_round", 2, "0=World triggered", "1=Round_Start")
  82. }
  83.  
  84. public plugin_precache()
  85. {
  86. precache_model("sprites/bhit.spr")
  87. precache_model("sprites/richo1.spr")
  88. }
  89.  
  90. stock worldInVicinity(Float:origin[3]) {
  91. new ent = find_ent_in_sphere(-1, origin, 4.0)
  92. while(ent > 0)
  93. {
  94. if(entity_get_float(ent, EV_FL_health) > 0 || entity_get_float(ent, EV_FL_takedamage) > 0.0)
  95. return 0
  96. ent = find_ent_in_sphere(ent, origin, 4.0)
  97. }
  98.  
  99. new Float:traceEnds[8][3], Float:traceHit[3], hitEnt
  100.  
  101. traceEnds[0][0] = origin[0] - 2.0
  102. traceEnds[0][1] = origin[1] - 2.0
  103. traceEnds[0][2] = origin[2] - 2.0
  104.  
  105. traceEnds[1][0] = origin[0] - 2.0
  106. traceEnds[1][1] = origin[1] - 2.0
  107. traceEnds[1][2] = origin[2] + 2.0
  108.  
  109. traceEnds[2][0] = origin[0] + 2.0
  110. traceEnds[2][1] = origin[1] - 2.0
  111. traceEnds[2][2] = origin[2] + 2.0
  112.  
  113. traceEnds[3][0] = origin[0] + 2.0
  114. traceEnds[3][1] = origin[1] - 2.0
  115. traceEnds[3][2] = origin[2] - 2.0
  116.  
  117. traceEnds[4][0] = origin[0] - 2.0
  118. traceEnds[4][1] = origin[1] + 2.0
  119. traceEnds[4][2] = origin[2] - 2.0
  120.  
  121. traceEnds[5][0] = origin[0] - 2.0
  122. traceEnds[5][1] = origin[1] + 2.0
  123. traceEnds[5][2] = origin[2] + 2.0
  124.  
  125. traceEnds[6][0] = origin[0] + 2.0
  126. traceEnds[6][1] = origin[1] + 2.0
  127. traceEnds[6][2] = origin[2] + 2.0
  128.  
  129. traceEnds[7][0] = origin[0] + 2.0
  130. traceEnds[7][1] = origin[1] + 2.0
  131. traceEnds[7][2] = origin[2] - 2.0
  132.  
  133. for (new i = 0; i < 8; i++) {
  134. if (PointContents(traceEnds[i]) != CONTENTS_EMPTY)
  135. {
  136. return 1
  137. }
  138.  
  139. hitEnt = trace_line(0, origin, traceEnds[i], traceHit)
  140. if (hitEnt != -1)
  141. {
  142. return 1
  143. }
  144. for (new j = 0; j < 3; j++) {
  145. if (traceEnds[i][j] != traceHit[j])
  146. {
  147. return 1
  148. }
  149. }
  150. }
  151.  
  152. return 0
  153. }
  154.  
  155. public make_paint(id)
  156. {
  157. new wpn = read_data(2)
  158. new ammo = read_data(3)
  159.  
  160. new CsTeams:playert = cs_get_user_team(id)
  161.  
  162. if(get_pcvar_num(paintball) == 1 && lastwpn[id] == wpn && lastammo[id] > ammo)
  163. {
  164. new iOrigin[3]
  165. get_user_origin(id, iOrigin, 4)
  166. new Float:fOrigin[3]
  167. IVecFVec(iOrigin, fOrigin)
  168.  
  169. if(g_ballsnum < get_pcvar_num(paintball_maxballs) /*get_num_ents() < (global_get_int(GV_INT_maxEntities) - 100)*/ && worldInVicinity(fOrigin))
  170. {
  171. new ent = create_entity("info_target")
  172. if(ent > 0)
  173. {
  174. entity_set_string(ent, EV_SZ_classname, "paint_ent")
  175. entity_set_int(ent, EV_INT_movetype, 0)
  176. entity_set_int(ent, EV_INT_solid, 0)
  177. entity_set_model(ent, g_paintSprite[random_num(0,1)])
  178. new r, g, b
  179. if(get_pcvar_num(paintball_randomcolor) == 0)
  180. {
  181. new i = random_num(0, MAX_COLORS-1)
  182. r = g_paintColors[i][0]
  183. g = g_paintColors[i][1]
  184. b = g_paintColors[i][2]
  185. }
  186. else if(get_pcvar_num(paintball_randomcolor) == 1)
  187. {
  188. r = random_num(64,255)
  189. g = random_num(64,255)
  190. b = random_num(64,255)
  191. }
  192.  
  193. else if(get_pcvar_num(paintball_randomcolor) == 2)
  194. {
  195. if(playert == CS_TEAM_CT)
  196. {
  197. r = 0
  198. g = 0
  199. b = 255
  200. }
  201.  
  202. else
  203. {
  204. r = 255
  205. g = 0
  206. b = 0
  207. }
  208. }
  209.  
  210. set_rendering(ent, kRenderFxNoDissipation, r, g, b, kRenderGlow, 255)
  211. entity_set_origin(ent, fOrigin)
  212. entity_set_int(ent, EV_INT_flags, FL_ALWAYSTHINK)
  213. entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(paintball_lifetime))
  214. ++g_ballsnum
  215. }
  216. }
  217. }
  218. lastwpn[id] = wpn
  219. lastammo[id] = ammo
  220. }
  221.  
  222. public pfn_think(entity) {
  223. if(entity > 0) {
  224. new class[32]
  225. entity_get_string(entity, EV_SZ_classname, class, 31)
  226. if(equal(class, "paint_ent")) {
  227. remove_entity(entity)
  228. --g_ballsnum
  229. }
  230. }
  231. }
  232.  
  233. public new_round()
  234. {
  235. remove_entity_name("paint_ent")
  236. g_ballsnum = 0
  237. }
  238.  
  239.  
  240.  
  241. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  242. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  243. */
  244.