HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3.  
  4. #define PLUGIN "Weapon Trail"
  5. #define VERSION "2.0"
  6. #define AUTHOR "anakin_cstrike"
  7.  
  8. #define MAX_PLAYERS 32
  9. #define OFFSET_ENT_TO_INDEX 43
  10.  
  11. enum droptype
  12. {
  13. droptype_manual,
  14. droptype_ondeath
  15. }
  16. new
  17. toggle,light,vel,g_max_clients,g_max_entities;
  18.  
  19. new const g_drop[] = "drop";
  20. new const g_wbox_class[] = "weaponbox";
  21. new const g_wbox_model[] = "models/w_weaponbox.mdl";
  22. new const g_wbox_model_prefix[] = "models/w_";
  23. new const g_start_client_index = 1;
  24. new g_command[MAX_PLAYERS + 1][sizeof g_drop + 1];
  25. new g_trail,r,g,b;
  26. public plugin_init()
  27. {
  28. register_plugin(PLUGIN, VERSION, AUTHOR);
  29. register_forward(FM_SetModel, "fw_setmodel");
  30. register_forward(FM_Touch,"fw_touch");
  31. toggle = register_cvar("weapontrail","1");
  32. light = register_cvar("weapontrail_light","1");
  33. vel = register_cvar("weapontrail_vel","1");
  34. g_max_clients = global_get(glb_maxClients);
  35. g_max_entities = global_get(glb_maxEntities);
  36. }
  37. public plugin_precache()
  38. g_trail = precache_model("sprites/smoke.spr");
  39. public client_command(id)
  40. read_argv(0, g_command[id], sizeof g_drop);
  41. public fw_setmodel(ent, const model[])
  42. {
  43. if(get_pcvar_num(toggle) != 1)
  44. return FMRES_IGNORED;
  45. if(!pev_valid(ent) || !equal(model, g_wbox_model_prefix, sizeof g_wbox_model_prefix - 1) || equal(model, g_wbox_model))
  46. return FMRES_IGNORED;
  47. new id = pev(ent, pev_owner)
  48. if(!(g_start_client_index <= id <= g_max_clients))
  49. return FMRES_IGNORED;
  50. static class[32],i;
  51. pev(ent,pev_classname,class, sizeof class - 1)
  52. if(!equal(class,g_wbox_class))
  53. return FMRES_IGNORED;
  54. for(i = g_max_clients + 1;i < g_max_entities;++i)
  55. {
  56. if(!pev_valid(i) || ent != pev(i, pev_owner))
  57. continue;
  58.  
  59. new wid = get_pdata_int(i,OFFSET_ENT_TO_INDEX);
  60. if(wid != CSW_C4)
  61. {
  62. new droptype:drop_type;
  63. if(!is_user_alive(id))
  64. drop_type = droptype_ondeath;
  65. else if(equal(g_command[id], g_drop))
  66. drop_type = droptype_manual;
  67. else
  68. return FMRES_IGNORED;
  69. switch(drop_type)
  70. {
  71. case droptype_ondeath: {
  72. if(get_user_team(id) == 1){r=255;g=0;b=0;}
  73. else if(get_user_team(id) == 2){r=0;g=0;b=255;}
  74. }
  75. case droptype_manual: {
  76. r = random(255);
  77. g = random(255);
  78. b = random(255);
  79. }
  80. }
  81. if(get_pcvar_num(vel) == 1)
  82. {
  83. new Float:vel[3];
  84. vel[0] = float(random(300));
  85. vel[1] = float(random(300));
  86. vel[2] = float(random(300));
  87. set_pev(ent,pev_velocity,vel);
  88. }
  89. message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  90. write_byte(TE_BEAMFOLLOW);
  91. write_short(ent);
  92. write_short(g_trail);
  93. write_byte(5);
  94. write_byte(5);
  95. write_byte(r);
  96. write_byte(g);
  97. write_byte(b);
  98. write_byte(195);
  99. message_end();
  100. }
  101. }
  102. return FMRES_IGNORED;
  103. }
  104. public fw_touch(touched, toucher)
  105. {
  106. if(get_pcvar_num(toggle) != 1)
  107. return FMRES_IGNORED;
  108. if(get_pcvar_num(light) != 1)
  109. return FMRES_IGNORED;
  110.  
  111. static class[32];
  112. pev(toucher, pev_classname, class, sizeof class - 1);
  113.  
  114. if(containi(class, "weapon") != -1 && !touched)
  115. {
  116. new Float:origin[3];
  117. pev(toucher, pev_origin, origin);
  118.  
  119. message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  120. write_byte(TE_DLIGHT);
  121. write_coord(floatround(origin[0]));
  122. write_coord(floatround(origin[1]));
  123. write_coord(floatround(origin[2]));
  124. write_byte(20);
  125. write_byte(r);
  126. write_byte(g);
  127. write_byte(b);
  128. write_byte(5);
  129. write_byte(20);
  130. message_end();
  131. }
  132. return FMRES_IGNORED;
  133. }
  134.