Advertisement
RevolutionHD

Untitled

Nov 8th, 2017
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.22 KB | None | 0 0
  1. Pozdrav,
  2.  
  3. Imam jedno pitanje dali je moguce ovaj trail plugin da stavim da bude samo za admine?
  4.  
  5. [PHP]/*****************************************************************************************
  6. *
  7. * plugin_trail.sma
  8. *
  9. * By Bahrmanou (amiga5707@hotmail.com)
  10. *
  11. *****************************************************************************************/
  12. /*****************************************************************************************
  13. If some map cause problem (crash the server) because of too much precaches, create a file
  14. in your AmxModx configs folder named 'sensiblemaps.cfg' and add the map name (WITHOUT the
  15. extension '.bsp') in that file.
  16. So if the map is in the list, the plugin prevents trail sprites to be precached (i.e. the
  17. trails are DISABLED for this map.
  18. *****************************************************************************************/
  19. #include <amxmodx>
  20. #include <amxmisc>
  21. #include <engine>
  22.  
  23. #define PLUGNAME "plugin_trail"
  24. #define VERSION "1.3.1"
  25. #define AUTHOR "Bahrmanou"
  26.  
  27. #define ACCESS_LEVEL ADMIN_LEVEL_A
  28. #define ACCESS_ADMIN ADMIN_ADMIN
  29.  
  30. #define MAX_TEXT_LENGTH 200
  31. #define MAX_NAME_LENGTH 40
  32. #define MAX_PLAYERS 32
  33. #define MAX_DISTANCE 300
  34.  
  35. #define CFG_FILE "colors.cfg"
  36. #define MAX_COLORS 200
  37.  
  38. #define DEF_TRAIL_LIFE 2
  39.  
  40. #define TASKID 1337 // change if it interfere with another plugin!
  41. #define TICK 0.1
  42.  
  43. #define NUM_SPRITES 12
  44.  
  45. new bool:gl_parsed
  46. new bool:gl_trail
  47. new bool:gl_not_this_map
  48.  
  49. new gl_trail_life
  50. new gl_trail_size[MAX_PLAYERS]
  51. new gl_trail_brightness[MAX_PLAYERS]
  52. new gl_trail_type[MAX_PLAYERS]
  53.  
  54. new gl_sprite_name[NUM_SPRITES][] = {
  55. "sprites/laserbeam.spr",
  56. "sprites/blueflare1.spr",
  57. "sprites/dot.spr",
  58. "sprites/flare5.spr",
  59. "sprites/flare6.spr",
  60. "sprites/plasma.spr",
  61. "sprites/smoke.spr",
  62. "sprites/xbeam5.spr",
  63. "sprites/xenobeam.spr",
  64. "sprites/xssmke1.spr",
  65. "sprites/zbeam3.spr",
  66. "sprites/zbeam2.spr"
  67. }
  68. new gl_sprite[NUM_SPRITES]
  69. new gl_def_sprite_size[NUM_SPRITES] = {
  70. 5, 12, 4, 16, 16, 6, 9, 4, 15, 14, 15, 20
  71. }
  72. new gl_def_sprite_brightness[NUM_SPRITES] = {
  73. 160, 255, 200, 255, 255, 230, 150, 150, 240, 220, 200, 200
  74. }
  75.  
  76. new gl_players[MAX_PLAYERS]
  77.  
  78. new gl_player_position[MAX_PLAYERS][3]
  79. new gl_timer_count[MAX_PLAYERS]
  80. new gl_timer_limit
  81.  
  82. new gl_player_colors[MAX_PLAYERS][3]
  83. new gl_color_names[MAX_COLORS][MAX_NAME_LENGTH]
  84. new gl_colors[MAX_COLORS][3]
  85. new gl_num_colors
  86.  
  87. public plugin_init() {
  88. register_plugin(PLUGNAME, VERSION, AUTHOR)
  89. register_concmd("amx_trail","cmdTrail", ACCESS_LEVEL, "- ['on'|'off'|'1'|'0'] : enable/disable trails.")
  90. register_concmd("amx_trail_user","cmdUserTrail", ACCESS_LEVEL, "- <name or #userid> <colorname | 'random' | 'off'> : set user trail.")
  91. register_concmd("amx_trail_type", "cmdTrailType", ACCESS_LEVEL, "- <type> : set trail type for all players.")
  92. register_concmd("amx_trail_life","cmdTrailLife", ACCESS_LEVEL, "- [duration] : get/set trail duration, in seconds.")
  93. register_concmd("amx_trail_size","cmdTrailSize", ACCESS_LEVEL, "- [size] : get/set trail size.")
  94. register_concmd("amx_trail_brightness","cmdTrailBrightness", ACCESS_LEVEL, "- [brightness] : get/set trail brightness.")
  95. register_concmd("amx_trail_reload", "cmdReload", ACCESS_LEVEL, ": reload colors configuration file.")
  96. register_clcmd("say", "SayCmd", 0, "")
  97.  
  98. gl_parsed = gl_trail = parse_file()
  99. if (!gl_sprite[0]) gl_trail = false
  100.  
  101. gl_trail_life = DEF_TRAIL_LIFE
  102. gl_timer_limit = floatround(float(gl_trail_life)/TICK)
  103. }
  104.  
  105. public plugin_modules() {
  106. require_module("engine")
  107. }
  108.  
  109. public plugin_precache() {
  110. if (check_map()) {
  111. gl_not_this_map = true
  112. return
  113. }
  114.  
  115. for (new i=0; i<NUM_SPRITES; i++) {
  116. gl_sprite[i] = precache_model(gl_sprite_name[i])
  117. }
  118. }
  119.  
  120. public client_putinserver(id) {
  121. gl_trail_type[id] = gl_sprite[0]
  122. gl_trail_size[id] = gl_def_sprite_size[0]
  123. gl_trail_brightness[id] = gl_def_sprite_brightness[0]
  124. }
  125.  
  126. public client_disconnect(id) {
  127. if (task_exists(TASKID+id)) remove_task(TASKID+id)
  128. gl_player_colors[id][0] = gl_player_colors[id][1] = gl_player_colors[id][2] = 0
  129. }
  130.  
  131. /*****************************************************************************************
  132. *
  133. * cmdTrail ['on'|'off'|'1'|'0'] : enable/disable trails.
  134. *
  135. *****************************************************************************************/
  136. public cmdTrail(id, level, cid) {
  137. if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
  138.  
  139. if (!gl_parsed) {
  140. console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE)
  141. return PLUGIN_HANDLED
  142. }
  143. if (gl_not_this_map) {
  144. console_print(id, "Trails are disabled for this map!")
  145. return PLUGIN_HANDLED
  146. }
  147.  
  148. new str[5]
  149. read_argv(1, str, 4)
  150. if (equali(str, "on") || equali(str, "1")) {
  151. if (gl_trail) {
  152. console_print(id, "Trails are already enabled.")
  153. } else {
  154. gl_trail = true
  155. console_print(id, "Trails are now ENABLED.")
  156. }
  157. } else if (equali(str, "off") || equali(str, "0")) {
  158. if (!gl_trail) {
  159. console_print(id, "Trails are already disabled.")
  160. }else {
  161. gl_trail = false
  162. new playercount
  163. get_players(gl_players, playercount)
  164. for (new i=0; i<playercount; i++) {
  165. kill_trail_task(gl_players[i])
  166. }
  167. say_to_all("Your trail has been removed.", id)
  168. console_print(id, "Trails are now DISABLED.")
  169. }
  170. } else {
  171. if (gl_trail) {
  172. console_print(id, "Trails are ENABLED.")
  173. } else {
  174. console_print(id, "Trails are DISABLED.")
  175. }
  176. }
  177.  
  178. return PLUGIN_HANDLED
  179. }
  180.  
  181. /*****************************************************************************************
  182. *
  183. * cmdUserTrail <name or #userid> <colorname | 'random' | 'off'> : set user trail.
  184. *
  185. *****************************************************************************************/
  186. public cmdUserTrail(id, level, cid) {
  187. if (!cmd_access(id, level, cid, 3)) return PLUGIN_HANDLED
  188.  
  189. if (!gl_parsed) {
  190. console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE)
  191. return PLUGIN_HANDLED
  192. }
  193. if (gl_not_this_map) {
  194. console_print(id, "Trails are disabled for this map!")
  195. return PLUGIN_HANDLED
  196. }
  197.  
  198. new user[MAX_NAME_LENGTH+1], colorname[MAX_NAME_LENGTH]
  199. new plName[MAX_NAME_LENGTH+1]
  200.  
  201. read_argv(1, user, MAX_NAME_LENGTH)
  202. read_argv(2, colorname, MAX_NAME_LENGTH-1)
  203.  
  204. new player = cmd_target(id, user, 6)
  205. if (!player) {
  206. console_print(id, "Unknown player: %s", user)
  207. return PLUGIN_HANDLED
  208. }
  209. get_user_name(player, plName, MAX_NAME_LENGTH)
  210. if (access(player, ADMIN_IMMUNITY) && id!=player) {
  211. console_print(id, "You cannot do that to %s, you silly bear!", plName)
  212. return PLUGIN_HANDLED
  213. }
  214. if (!is_user_alive(player)) {
  215. console_print(id, "Only alive players, please!")
  216. return PLUGIN_HANDLED
  217. }
  218.  
  219. if (equali(colorname, "off")) {
  220. if (!gl_player_colors[player][0] && !gl_player_colors[player][1] && !gl_player_colors[player][2]) {
  221. console_print(id, "The %s's trail is already off!", plName)
  222. return PLUGIN_HANDLED
  223. }
  224. kill_trail_task(player)
  225. console_print(id, "The %s's trail has been removed.", plName)
  226. client_print(player, print_chat, "Your trail has been removed.")
  227. } else if (equali(colorname, "random")) {
  228. do_trail(player, "", "")
  229. console_print(id, "%s has now a random color trail.", plName)
  230. } else {
  231. do_trail(player, colorname, "")
  232. console_print(id, "%s has now a %s trail.", plName, colorname)
  233. }
  234.  
  235. return PLUGIN_HANDLED
  236. }
  237.  
  238. /*****************************************************************************************
  239. *
  240. * cmdTrailType <type> : set trail type (sprite) for all players
  241. *
  242. *****************************************************************************************/
  243. public cmdTrailType(id, level, cid) {
  244. if (!cmd_access(id, level, cid, 2)) return PLUGIN_HANDLED
  245.  
  246. if (!gl_parsed) {
  247. console_print(id, "Trails are OFF becaus I couldn't read the config file '%s'!", CFG_FILE)
  248. return PLUGIN_HANDLED
  249. }
  250. if (gl_not_this_map) {
  251. console_print(id, "Trails are disabled for this map!")
  252. return PLUGIN_HANDLED
  253. }
  254.  
  255. new str[5], type
  256. read_argv(1, str, 4)
  257. type = str_to_num(str)
  258. if (type<1 || type>NUM_SPRITES) {
  259. console_print(id, "Type must be in [1,%d] range!", NUM_SPRITES)
  260. return PLUGIN_HANDLED
  261. }
  262. for (new i=0; i<MAX_PLAYERS; i++) {
  263. gl_trail_type[i] = gl_sprite[type-1]
  264. gl_trail_size[i] = gl_def_sprite_size[type-1]
  265. gl_trail_brightness[i] = gl_def_sprite_brightness[type-1]
  266. }
  267. restart_player_trail(id)
  268. return PLUGIN_HANDLED
  269. }
  270.  
  271. /*****************************************************************************************
  272. *
  273. * cmdTrailLife [duration] : get/set trail duration, in seconds.
  274. *
  275. *****************************************************************************************/
  276. public cmdTrailLife(id, level, cid) {
  277. if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
  278.  
  279. if (!gl_parsed) {
  280. console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE)
  281. return PLUGIN_HANDLED
  282. }
  283. if (gl_not_this_map) {
  284. console_print(id, "Trails are disabled for this map!")
  285. return PLUGIN_HANDLED
  286. }
  287.  
  288. new Str[3], life
  289.  
  290. read_argv(1, Str, 2)
  291. if (!Str[0]) {
  292. console_print(id, "Trail life is currently %d seconds.", gl_trail_life)
  293. return PLUGIN_HANDLED
  294. }
  295. life = str_to_num(Str)
  296. if (life<1 || life>30) {
  297. console_print(id, "Trail life must be in [1,30] range!")
  298. return PLUGIN_HANDLED
  299. }
  300. gl_trail_life = life
  301. gl_timer_limit = floatround(float(life)/TICK)
  302. restart_players_trails()
  303.  
  304. return PLUGIN_HANDLED
  305. }
  306.  
  307. /*****************************************************************************************
  308. *
  309. * cmdTrailSize [size] : get/set trail size.
  310. *
  311. *****************************************************************************************/
  312. public cmdTrailSize(id, level, cid) {
  313. if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
  314.  
  315. if (!gl_parsed) {
  316. console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE)
  317. return PLUGIN_HANDLED
  318. }
  319. if (gl_not_this_map) {
  320. console_print(id, "Trails are disabled for this map!")
  321. return PLUGIN_HANDLED
  322. }
  323.  
  324. new Str[3], size
  325.  
  326. read_argv(1, Str, 2)
  327. if (!Str[0]) {
  328. console_print(id, "Your trail size is currently %d.", gl_trail_size[id])
  329. return PLUGIN_HANDLED
  330. }
  331. size = str_to_num(Str)
  332. if (size<1) {
  333. console_print(id, "Trail size must be positive!")
  334. return PLUGIN_HANDLED
  335. }
  336. gl_trail_size[id] = size
  337. restart_player_trail(id)
  338.  
  339. return PLUGIN_HANDLED
  340. }
  341.  
  342. /*****************************************************************************************
  343. *
  344. * cmdTrailBrightness [brightness] : get/set trail brightness.
  345. *
  346. *****************************************************************************************/
  347. public cmdTrailBrightness(id, level, cid) {
  348. if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
  349.  
  350. if (!gl_parsed) {
  351. console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE)
  352. return PLUGIN_HANDLED
  353. }
  354. if (gl_not_this_map) {
  355. console_print(id, "Trails are disabled for this map!")
  356. return PLUGIN_HANDLED
  357. }
  358.  
  359. new Str[3], bright
  360.  
  361. read_argv(1, Str, 3)
  362. if (!Str[0]) {
  363. console_print(id, "Your trail brightness is currently %d.", gl_trail_brightness[id])
  364. return PLUGIN_HANDLED
  365. }
  366. bright = str_to_num(Str)
  367. if (bright<1 || bright>255) {
  368. console_print(id, "Brightness must be in [1,255] range!")
  369. return PLUGIN_HANDLED
  370. }
  371. gl_trail_brightness[id] = bright
  372. restart_player_trail(id)
  373.  
  374. return PLUGIN_HANDLED
  375. }
  376.  
  377. /*****************************************************************************************
  378. *
  379. * cmdReload : reload configuration file.
  380. *
  381. *****************************************************************************************/
  382. public cmdReload(id, level, cid) {
  383. if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
  384.  
  385. if (gl_not_this_map) {
  386. console_print(id, "Trails are disabled for this map!")
  387. return PLUGIN_HANDLED
  388. }
  389.  
  390. gl_parsed = parse_file()
  391.  
  392. if (gl_parsed) {
  393. console_print(id, "Ok, configuration file successfuly reloaded.")
  394. } else {
  395. console_print(id, "Uh Oh...There was a problem! Please check your amx log file to know whats causing this.")
  396. }
  397. return PLUGIN_HANDLED
  398. }
  399.  
  400. /*****************************************************************************************
  401. *
  402. * sayCmd : say trail <[['light'|'dark'] colorname] | ['random'] | ['off'] | ['help']>
  403. *
  404. *****************************************************************************************/
  405. public SayCmd(id, level, cid) {
  406. new args[128], msg[200], plName[MAX_NAME_LENGTH], colname[MAX_NAME_LENGTH], arg2[MAX_NAME_LENGTH], arg3[MAX_NAME_LENGTH], typenum
  407.  
  408. read_args(args, 128)
  409. remove_quotes(args)
  410.  
  411. if (equali(args, "trail", 5)) {
  412. if (!gl_trail) {
  413. client_print(id, print_chat, "Trails have been disabled.")
  414. return PLUGIN_HANDLED
  415. }
  416. if (gl_not_this_map) {
  417. client_print(id, print_chat, "Trails have been disabled for this map.")
  418. return PLUGIN_HANDLED
  419. }
  420.  
  421. get_user_name(id, plName, MAX_NAME_LENGTH)
  422. if (!get_user_team(id) && !access(id, ADMIN_ADMIN)) {
  423. client_print(id, print_chat, "You must be playing!")
  424. return PLUGIN_HANDLED
  425. }
  426.  
  427. if (!args[5]) {
  428. do_trail(id, "", "")
  429. return PLUGIN_HANDLED
  430. } else {
  431. parse(args[6], colname, MAX_NAME_LENGTH, arg2, MAX_NAME_LENGTH, arg3, MAX_NAME_LENGTH)
  432. // console_print(id, "restline = '%s'", restline)
  433. typenum = str_to_num(colname)
  434. }
  435.  
  436. if (equali(colname, "off")) {
  437. if (!gl_player_colors[id][0] && !gl_player_colors[id][1] && !gl_player_colors[id][2]) {
  438. client_print(id, print_chat, "Your trail is already off!")
  439. return PLUGIN_HANDLED
  440. }
  441. kill_trail_task(id)
  442. client_print(id, print_chat, "Your trail was removed.")
  443. format(msg, 199, "%s's trail was removed.", plName)
  444. say_to_all(msg, id)
  445. return PLUGIN_HANDLED
  446. } else if (equali(colname, "random")) {
  447. do_trail(id, "", "")
  448. return PLUGIN_HANDLED
  449. } else if (equali(colname, "help")) {
  450. trail_help(id)
  451. return PLUGIN_HANDLED
  452. }
  453.  
  454. if (typenum) {
  455. if (typenum<1 || typenum>NUM_SPRITES) {
  456. client_print(id, print_chat, "Type must be in the range [1,%d].", NUM_SPRITES)
  457. return PLUGIN_HANDLED
  458. }
  459. typenum--
  460. gl_trail_type[id] = gl_sprite[typenum]
  461. gl_trail_size[id] = gl_def_sprite_size[typenum]
  462. gl_trail_brightness[id] = gl_def_sprite_brightness[typenum]
  463. if (arg2[0]) {
  464. colname = arg2
  465. arg2 = arg3
  466. } else {
  467. if (!gl_player_colors[id][0] && !gl_player_colors[id][1] && !gl_player_colors[id][2]) {
  468. do_trail(id, "", "")
  469. return PLUGIN_HANDLED
  470. }
  471. new r = gl_player_colors[id][0]
  472. new g = gl_player_colors[id][1]
  473. new b = gl_player_colors[id][2]
  474. kill_trail_task(id)
  475. gl_player_colors[id][0] = r
  476. gl_player_colors[id][1] = g
  477. gl_player_colors[id][2] = b
  478. get_user_origin(id, gl_player_position[id])
  479. set_task(TICK, "check_position", TASKID+id, "", 0, "b")
  480. trail_msg(id)
  481. client_print(id, print_chat, "You have a trail of type %d.", typenum+1)
  482. format(msg, 199, "%s has a type %d trail.", plName, typenum+1)
  483. say_to_all(msg, id)
  484. return PLUGIN_HANDLED
  485. }
  486. }
  487.  
  488. if (equali(colname, "dark")) {
  489. copy(colname, MAX_NAME_LENGTH-1, arg2)
  490. if (!colname[0]) {
  491. client_print(id, print_chat, "Specify a color name!")
  492. return PLUGIN_HANDLED
  493. }
  494. do_trail(id, colname, "dark")
  495. } else if (equali(colname, "light")) {
  496. copy(colname, MAX_NAME_LENGTH-1, arg2)
  497. if (!colname[0]) {
  498. client_print(id, print_chat, "Specify a color name!")
  499. return PLUGIN_HANDLED
  500. }
  501. do_trail(id, colname, "light")
  502. }
  503. else {
  504. do_trail(id, colname, "")
  505. }
  506. }
  507. return PLUGIN_CONTINUE
  508. }
  509.  
  510. /*****************************************************************************************
  511. *****************************************************************************************/
  512. do_trail(id, colname[], intensity[]) {
  513. new i, msg[200]
  514. new name[33]
  515.  
  516. get_user_name(id, name, 32)
  517. if (!colname[0]) {
  518. kill_trail_task(id)
  519. gl_player_colors[id][0] = random(256)
  520. gl_player_colors[id][1] = random(256)
  521. gl_player_colors[id][2] = random(256)
  522. get_user_origin(id, gl_player_position[id])
  523. set_task(TICK, "check_position", TASKID+id, "", 0, "b")
  524. trail_msg(id)
  525. client_print(id, print_chat, "You have a random color trail.")
  526. format(msg, 199, "%s has a random color trail.", name)
  527. say_to_all(msg, id)
  528. return
  529. }
  530. for (i=0; i<gl_num_colors; i++) {
  531. if (equali(colname, gl_color_names[i])) {
  532. new Float:intens, r, g, b
  533. if (equali(intensity, "dark")) {
  534. intens = 0.5
  535. } else if (equali(intensity, "light")) {
  536. intens = 2.0
  537. } else {
  538. copy(intensity, 1, "")
  539. intens = 1.0
  540. }
  541. kill_trail_task(id)
  542. r = floatround(float(gl_colors[i][0]) * intens)
  543. g = floatround(float(gl_colors[i][1]) * intens)
  544. b = floatround(float(gl_colors[i][2]) * intens)
  545. gl_player_colors[id][0] = min(r, 255)
  546. gl_player_colors[id][1] = min(g, 255)
  547. gl_player_colors[id][2] = min(b, 255)
  548. get_user_origin(id, gl_player_position[id])
  549. set_task(TICK, "check_position", TASKID+id, "", 0, "b")
  550. trail_msg(id)
  551. if (intensity[0]) {
  552. client_print(id, print_chat, "You have a %s %s trail.", intensity, colname)
  553. format(msg, 199, "%s has now a %s %s trail.", name, intensity, colname)
  554. } else {
  555. client_print(id, print_chat, "You have a %s trail.", colname)
  556. format(msg, 199, "%s has now a %s trail.", name, colname)
  557. }
  558. say_to_all(msg, id)
  559. return
  560. }
  561. }
  562. client_print(id, print_chat, "Sorry, %s, but I dont recognize the color '%s'!", name, colname)
  563. return
  564. }
  565.  
  566. /*****************************************************************************************
  567. *****************************************************************************************/
  568. public check_position(taskid) {
  569. new origin[3], id = taskid-TASKID
  570.  
  571. if (!get_user_team(id)) {
  572. kill_trail_msg(id)
  573. return
  574. }
  575.  
  576. get_user_origin(id, origin)
  577. if (origin[0]!=gl_player_position[id][0] || origin[1]!=gl_player_position[id][1] || origin[2]!=gl_player_position[id][2]) {
  578. if (get_distance(origin, gl_player_position[id])>MAX_DISTANCE || gl_timer_count[id] >= gl_timer_limit/2) {
  579. kill_trail_msg(id)
  580. trail_msg(id)
  581. }
  582. gl_player_position[id][0] = origin[0]
  583. gl_player_position[id][1] = origin[1]
  584. gl_player_position[id][2] = origin[2]
  585. gl_timer_count[id] = 0
  586. } else {
  587. if (gl_timer_count[id] < gl_timer_limit) gl_timer_count[id]++
  588. }
  589. }
  590.  
  591. /*****************************************************************************************
  592. *****************************************************************************************/
  593. kill_trail_task(id) {
  594. if (task_exists(TASKID+id)) remove_task(TASKID+id)
  595. kill_trail_msg(id)
  596. gl_player_colors[id][0] = gl_player_colors[id][1] = gl_player_colors[id][2] = 0
  597. }
  598.  
  599. /*****************************************************************************************
  600. *****************************************************************************************/
  601. kill_trail_msg(id) {
  602. gl_timer_count[id] = 0
  603.  
  604. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  605. write_byte(99) // TE_KILLBEAM
  606. write_short(id)
  607. message_end()
  608. }
  609.  
  610. /*****************************************************************************************
  611. *****************************************************************************************/
  612. trail_msg(id) {
  613. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  614. write_byte(22) // TE_BEAMFOLLOW
  615. write_short(id)
  616. write_short(gl_trail_type[id])
  617. write_byte(gl_trail_life*10)
  618. write_byte(gl_trail_size[id])
  619. write_byte(gl_player_colors[id][0])
  620. write_byte(gl_player_colors[id][1])
  621. write_byte(gl_player_colors[id][2])
  622. write_byte(gl_trail_brightness[id])
  623. message_end()
  624.  
  625. }
  626.  
  627. /*****************************************************************************************
  628. *****************************************************************************************/
  629. restart_player_trail(id) {
  630. if (task_exists(TASKID+id)) {
  631. remove_task(TASKID+id)
  632. kill_trail_msg(id)
  633. get_user_origin(id, gl_player_position[id])
  634. set_task(TICK, "check_position", TASKID+id, "", 0, "b")
  635. trail_msg(id)
  636. }
  637. }
  638.  
  639. /*****************************************************************************************
  640. *****************************************************************************************/
  641. restart_players_trails() {
  642. new playercount
  643.  
  644. get_players(gl_players, playercount)
  645. for (new i=0; i<playercount; i++) {
  646. restart_player_trail(gl_players[i])
  647. }
  648. }
  649.  
  650. /*****************************************************************************************
  651. *****************************************************************************************/
  652. say_to_all(msg[], id) {
  653. new playercount
  654.  
  655. get_players(gl_players, playercount)
  656. for (new i=0; i<playercount; i++) {
  657. if (gl_players[i]!=id) client_print(gl_players[i], print_chat, msg)
  658. }
  659. }
  660.  
  661. /*****************************************************************************************
  662. *****************************************************************************************/
  663. trail_help(id) {
  664. new msg[200], clen=0
  665.  
  666. console_print(id, "^nTrail Colors List:^n")
  667. for (new i=0; i<gl_num_colors; i++) {
  668. clen += format(msg[clen], 199-clen, "%s ", gl_color_names[i])
  669. if (clen > 80) {
  670. console_print(id, msg)
  671. copy(msg, 1, "")
  672. clen = 0
  673. }
  674. }
  675. console_print(id, "^nNOTE: All colors can be prefixed by the words 'light' or 'dark'.^n")
  676. console_print(id, "^nSay 'trail <color>' to get a colored trail.^nSay 'trail off' to turn trail off.")
  677. console_print(id, "Say 'trail <number> [color]' to change the look of the trail.^n")
  678. console_print(id, "^nExamples:")
  679. console_print(id, " trail")
  680. console_print(id, " trail off")
  681. console_print(id, " trail tomato")
  682. console_print(id, " trail 6 gold")
  683. console_print(id, " trail 11 light blue")
  684. client_print(id, print_chat, "The colors list has been displayed in your console.")
  685. }
  686.  
  687. /*****************************************************************************************
  688. *****************************************************************************************/
  689. bool:parse_file() {
  690. new got_line, line_num=0, len=0, parsed
  691. new r[3][4], g[3][4], b[3][4]
  692. new full_line[MAX_TEXT_LENGTH], rest_line[MAX_TEXT_LENGTH], cfgdir[MAX_TEXT_LENGTH], cfgpath[MAX_TEXT_LENGTH]
  693.  
  694. gl_num_colors = 0
  695. get_configsdir(cfgdir, MAX_TEXT_LENGTH)
  696. format(cfgpath, MAX_TEXT_LENGTH, "%s/%s", cfgdir, CFG_FILE)
  697. if (!file_exists(cfgpath)) {
  698. log_amx("ERROR: Cannot find configuration file '%s'!", cfgpath)
  699. return false
  700. }
  701. got_line = read_file(cfgpath, line_num, full_line, MAX_TEXT_LENGTH, len)
  702. if (got_line <=0) {
  703. log_amx("ERROR: Cannot read configuration file '%s'!", cfgpath)
  704. return false
  705. }
  706. while (got_line>0) {
  707. if (!equal(full_line, "//", 2) && len) {
  708. strtok(full_line, gl_color_names[gl_num_colors], MAX_NAME_LENGTH, rest_line, MAX_TEXT_LENGTH, ' ', 1)
  709. copy(full_line, MAX_TEXT_LENGTH, rest_line)
  710.  
  711. parsed = parse(full_line,r[0],3,g[0],3,b[0],3)
  712. if (parsed<3) {
  713. log_amx("ERROR: Not enough colors, line %d in configuration file '%s'!", 1+line_num, CFG_FILE)
  714. return false
  715. }
  716. gl_colors[gl_num_colors][0] = str_to_num(r[0])
  717. gl_colors[gl_num_colors][1] = str_to_num(g[0])
  718. gl_colors[gl_num_colors][2] = str_to_num(b[0])
  719.  
  720. gl_num_colors++
  721. if (gl_num_colors>=MAX_COLORS) {
  722. log_amx("WARNING: Max colors reached in file '%s'!", CFG_FILE)
  723. return true
  724. }
  725. }
  726. line_num++
  727. got_line = read_file(cfgpath, line_num, full_line, MAX_TEXT_LENGTH, len)
  728. }
  729. return true
  730. }
  731.  
  732. check_map() {
  733. new got_line, line_num, len
  734. new cfgdir[MAX_TEXT_LENGTH]
  735. new cfgpath[MAX_TEXT_LENGTH]
  736. new mapname[MAX_NAME_LENGTH]
  737. new txt[MAX_TEXT_LENGTH]
  738.  
  739. get_configsdir(cfgdir, MAX_TEXT_LENGTH-1)
  740. get_mapname(mapname, MAX_NAME_LENGTH-1)
  741.  
  742. format(cfgpath, MAX_TEXT_LENGTH, "%s/sensiblemaps.cfg", cfgdir)
  743.  
  744. if (file_exists(cfgpath)) {
  745. got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len)
  746. while (got_line>0) {
  747. if (equali(txt, mapname)) return 1
  748. line_num++
  749. got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len)
  750. }
  751. }
  752. return 0
  753. }
  754.  
  755. [/PHP]
  756.  
  757. Nasao sam ovaj plugin ovdje: https://forums.alliedmods.net/showthread.php?t=19328
  758. Meni samo treba neko da mi edituje da bude samo za admine!
  759. Kad kucam u chat trail 9 red ako sam admin da upali trail, a ako nisam da kaze nemam pristup!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement