HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*-----------------------------------------------------------
  2. [*] NightDM v1.1
  3.  * Copyright (C) 2015 Hartmann
  4.  - - - - - - - - - - -
  5.  AMX Mod X script.
  6.  
  7.   | Author : Hartmann
  8.   | Plugin : NightDM
  9.   | Version : v1.1
  10.  
  11.  (!) Support : Github - https://github.com/Hartmannq
  12.   AlliedModders - https://forums.alliedmods.net/showthread.php?t=265763
  13.  
  14.  This program is free software; you can redistribute it and/or
  15.  modify it under the terms of the GNU General Public License
  16.  as published by the Free Software Foundation; either version 2
  17.  of the License, or (at your option) any later version.
  18.  
  19.  This program is distributed in the hope that it will be useful,
  20.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22.  GNU General Public License for more details.
  23.  
  24.  You should have received a copy of the GNU General Public License
  25.  along with this program; if not, write to the Free Software
  26.  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  27.  
  28. - - - - - -
  29. Description:
  30.   - - - - - -
  31. Plugin puts in the time that you want dm mode.
  32. When the plugin is active is he doing next(when it comes your time, without changing the map):
  33.  
  34. - Remove object on map,
  35. - Block round end,
  36. - More spawn points,
  37. - Menu with weapon:
  38. + New Weapons
  39. + Last Weapons
  40. + 2 + Dont ask again
  41. - Remove buy zone,
  42. - Remove money(hud),
  43. - Remove(hud) and block timer,
  44. - Spawn protection,
  45. - HP for kill, hs, screen fade and give armor and granades on spawn,
  46. - Remove weapon on ground,
  47. - Every full BPAmmo,
  48. - ...
  49. When the finish time for dm everything back to normal, without changing the map.
  50. - - - - - -
  51. Cvars:
  52.   - - - - - -
  53. Auto-write cfg with all cvars in amxmodx/configs/NightDM.cfg
  54. Only this change, if you writing nodes to another CFG will have no effect.
  55. + dx_start 23 // Hour at which the DM start, example 2 = 2 am and 14 = 2 pm.
  56. + dx_end 9 // Hour at which the DM end, example 2 = 2 am and 14 = 2 pm.
  57. - TIME: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,00
  58. + dx_sptime 5 // The Player get godmode for X seconds and cant get damage.
  59. + dx_time 5 // Time for removing weapon on the ground.
  60. + dx_hp 15// HP for kill.
  61. + dx_hp_hs 40// HP for kill HS.
  62. + dx_max_hp 100// Maximum player's HP.
  63. + dx_armor 100 // Amout of armor to be given.
  64. + dx_prefix CSDM // Prefix
  65. + dx_msg_color "0 130 0" // Message color
  66. + dx_msg_xypos "0.02 0.2" // Message X Y
  67. + dx_msg 1 // Message. 1- On 0-off
  68. + dx_grenades "abc" // a - he grenade, b - smoke grenade, c - flashbang
  69. + dx_change "ab" // a - change sky on space, b - change lights on d
  70.  
  71.   - - - - - -
  72.   Changelog:
  73.   - - - - - -
  74.   v1.0 [4.jul.2015]
  75.   - First release.
  76. v1.1 [17.aug.2015]
  77. - Customizable Weapons list for Primary and Secondary weapons (ini file).
  78. - Added Multilingual support.
  79. - Added cvar for granades.
  80. - Added cvar for change space and lights.
  81. - Added cvar for message enable/disable, color and xy position.
  82. - Added print in color.
  83.  
  84. ------------------------------------------------------------*/
  85.  
  86. #include <amxmodx>
  87. #include <amxmisc>
  88. #include <engine>
  89. #include <hamsandwich>
  90. #include <fakemeta>
  91. #include <cstrike>
  92. #include <fun>
  93.  
  94. new PLUGIN[] = "NightDM";
  95. new AUTHOR[] = "Hartmann";
  96. new VERSION[] = "1.1";
  97.  
  98. #pragma semicolon 1
  99.  
  100. #define HUD_HIDE_MONEY (1<<5)
  101. #define HUD_HIDE_TIMER (1<<4)
  102. #define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0))
  103. #define MAX_SPAWNS 60
  104.  
  105. new const g_objective_ents[][] = {
  106. "func_bomb_target",
  107. "info_bomb_target",
  108. "hostage_entity",
  109. "monster_scientist",
  110. "func_hostage_rescue",
  111. "info_hostage_rescue",
  112. "info_vip_start",
  113. "func_vip_safetyzone",
  114. "func_escapezone"
  115. };
  116. new g_hWeaponMenu;
  117. new g_hPrimaryWeaponMenu;
  118. new g_hSecondaryWeaponMenu;
  119. new bool:g_bRememberGuns[ 33 ];
  120. new g_iPrimaryWeapon[ 33 ];
  121. new g_iSecondaryWeapon[ 33 ];
  122.  
  123. new bool:g_nightdm;
  124. new cvar_start;
  125. new cvar_end;
  126. new cvar_time;
  127. new message[80];
  128. new g_ClassName[] = "hud_info";
  129. new g_MsgSync1;
  130. new g_MsgSync2;
  131. new g_MsgSync3;
  132. new bool:g_restart;
  133. new bool:g_restart2;
  134. new gMaxClients;
  135. new pCvarTime;
  136. new normalsky[64];
  137. new configsDir[64];
  138. new dFile[256];
  139. new health_add;
  140. new health_hs_add;
  141. new health_max;
  142. new gmsgScreenFade;
  143. new gCvarArmor;
  144.  
  145. new g_WeaponBPAmmo[] ={
  146. 0, 52, 0, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120, 30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, 0, 100
  147. };
  148.  
  149. new g_WeaponSlots[] ={
  150. 0, 2, 0, 1, 4, 1, 5, 1, 1, 4, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 4, 2, 1, 1, 3, 1
  151. };
  152. new Float:g_SpawnVecs[MAX_SPAWNS][3];
  153. new Float:g_SpawnAngles[MAX_SPAWNS][3];
  154. new Float:g_SpawnVAngles[MAX_SPAWNS][3];
  155. new g_TotalSpawns;
  156. new CvarPrefix;
  157. new Prefix[ 32 ];
  158. new g_msg_color;
  159. new g_msg_xypos;
  160. new g_msg_enable;
  161. new g_grenades;
  162. new g_change;
  163. new g_szWepFile[256];
  164. new g_FilePointer;
  165. new Array:g_PrimaryWeapons;
  166. new Array:g_SecondaryWeapons;
  167.  
  168. public plugin_init() {
  169. register_plugin(PLUGIN, VERSION, AUTHOR);
  170.  
  171. register_cvar( "dx_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY);
  172.  
  173. CvarPrefix = register_cvar( "dx_prefix", "CSDM" );
  174. get_pcvar_string( CvarPrefix, Prefix, charsmax( Prefix ) );
  175. cvar_start = register_cvar("dx_start", "23");
  176. cvar_end = register_cvar("dx_end", "9");
  177. register_think(g_ClassName,"fw_Think");
  178. new iEnt = create_entity("info_target");
  179. entity_set_string(iEnt, EV_SZ_classname, g_ClassName);
  180. entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 1.0);
  181. g_MsgSync1 = CreateHudSyncObj();
  182. g_MsgSync2 = CreateHudSyncObj();
  183. g_MsgSync3 = CreateHudSyncObj();
  184. register_message( get_user_msgid( "HideWeapon" ), "msg_hideweapon" );
  185. RegisterHam( Ham_Spawn, "player", "FwdPlayerSpawnPost", 1 );
  186. RegisterHam(Ham_Killed, "player", "PlayerKilled", 1);
  187. register_message(get_user_msgid("StatusIcon"), "Message_StatusIcon");
  188. pCvarTime = register_cvar( "dx_time", "5" );
  189. RegisterHam( Ham_Touch, "weaponbox", "WeaponBox_Touch", 1 );
  190. register_event("CurWeapon","curweapon","be");
  191. cvar_time = register_cvar("dx_sptime", "5");
  192. gMaxClients = get_maxplayers();
  193. get_cvar_string("sv_skyname" , normalsky , 63);
  194. register_clcmd( "say /guns", "CmdGunsEnable" );
  195. health_add = register_cvar("dx_hp", "15");
  196. health_hs_add = register_cvar("dx_hp_hs", "40");
  197. health_max = register_cvar("dx_max_hp", "100");
  198. gCvarArmor = register_cvar( "dx_armor", "100" );
  199. register_event("DeathMsg", "eDeathMsg", "a");
  200. gmsgScreenFade = get_user_msgid("ScreenFade");
  201. register_event( "TeamInfo", "join_team", "a");
  202. g_msg_color = register_cvar("dx_msg_color","0 130 0");
  203. g_msg_xypos = register_cvar("dx_msg_xypos","0.02 0.2");
  204. g_msg_enable = register_cvar("dx_msg","1");
  205. g_grenades = register_cvar("dx_grenades","a");
  206. g_change = register_cvar("dx_change","ab");
  207. register_dictionary("nightdm.txt");
  208. readSpawns();
  209. CreateWeaponsArray();
  210. }
  211. public plugin_cfg()
  212. {
  213. get_configsdir(configsDir, charsmax(configsDir));
  214. formatex(dFile, charsmax(dFile), "%s/NightDM.cfg", configsDir);
  215. if(!file_exists(dFile))
  216. {
  217. write_file ( dFile , "--------------------------------------------" );
  218. write_file ( dFile , "NightDM v1.1 By Hartmann" );
  219. write_file ( dFile , "Copyright (C) 2015 Hartmann" );
  220. write_file ( dFile , "--------------------------------------------" );
  221. write_file ( dFile , "" );
  222. write_file ( dFile , "// Megjegyzés - A Cvarok módosítása után mapreset kell, hogy a módosítások érvénybe lépjenek!" );
  223. write_file ( dFile , "" );
  224. write_file ( dFile , "" );
  225. write_file ( dFile , "// Idő: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,00" );
  226. write_file ( dFile , "// Idő, mikor kezdődjön a DM MOD." );
  227. write_file ( dFile , "dx_start 23" );
  228. write_file ( dFile , "" );
  229. write_file ( dFile , "//Idő, mikor fejeződjön be a DM MOD." );
  230. write_file ( dFile , "dx_end 9" );
  231. write_file ( dFile , "" );
  232. write_file ( dFile , "// A játékos nem sebezhető X másodpercig." );
  233. write_file ( dFile , "dx_sptime 5" );
  234. write_file ( dFile , "" );
  235. write_file ( dFile , "//A fegyver eltűnik a földről a megadott X másodperc után." );
  236. write_file ( dFile , "dx_time 2" );
  237. write_file ( dFile , "" );
  238. write_file ( dFile , "// HP az Ölésért." );
  239. write_file ( dFile , "dx_hp 15" );
  240. write_file ( dFile , "" );
  241. write_file ( dFile , "// HP a Fejlövésért." );
  242. write_file ( dFile , "dx_hp_hs 40" );
  243. write_file ( dFile , "" );
  244. write_file ( dFile , "// Maximum játékos HP." );
  245. write_file ( dFile , "dx_max_hp 100" );
  246. write_file ( dFile , "" );
  247. write_file ( dFile , "// Pajzs értéke minden respawnkor." );
  248. write_file ( dFile , "dx_armor 100" );
  249. write_file ( dFile , "" );
  250. write_file ( dFile , "// Prefix" );
  251. write_file ( dFile , "dx_prefix CSDM" );
  252. write_file ( dFile , "" );
  253. write_file ( dFile , " // Üzenet színe" );
  254. write_file ( dFile , "dx_msg_color ^"0 130 0^"" );
  255. write_file ( dFile , "" );
  256. write_file ( dFile , "// Üzenet poziciója X Y" );
  257. write_file ( dFile , "dx_msg_xypos ^"0.02 0.2^"" );
  258. write_file ( dFile , "" );
  259. write_file ( dFile , "// Üzenet. 1- Be 0-Ki" );
  260. write_file ( dFile , "dx_msg 1" );
  261. write_file ( dFile , "" );
  262. write_file ( dFile , "//Gránátok" );
  263. write_file ( dFile , "// a - he gránát" );
  264. write_file ( dFile , "// b - füst gránát" );
  265. write_file ( dFile , "// c - flashbang" );
  266. write_file ( dFile , "// ^"^" - semmi." );
  267. write_file ( dFile , "dx_grenades ^"a^"" );
  268. write_file ( dFile , "" );
  269. write_file ( dFile , "//Változtatások" );
  270. write_file ( dFile , "// a - Változzon meg az égbolt" );
  271. write_file ( dFile , "// b - Legyen sötét" );
  272. write_file ( dFile , "// ^"^" - semmi." );
  273. write_file ( dFile , "dx_change ^"ab^"" );
  274. write_file ( dFile , "" );
  275. }
  276. }
  277. public plugin_end()
  278. {
  279. get_configsdir(configsDir, charsmax(configsDir));
  280. server_cmd("exec %s/NightDM.cfg", configsDir);
  281. }
  282. readSpawns(){
  283. //-617 2648 179 16 -22 0 0 -5 -22 0
  284. // Origin (x,y,z), Angles (x,y,z), vAngles(x,y,z), Team (0 = ALL) - ignore
  285. // :TODO: Implement team specific spawns
  286.  
  287. new Map[32], config[32], MapFile[64];
  288.  
  289. get_mapname(Map, 31);
  290. get_configsdir(config, 31 );
  291. format(MapFile, 63, "%s\csdm\%s.spawns.cfg", config, Map);
  292. g_TotalSpawns = 0;
  293.  
  294. if (file_exists(MapFile))
  295. {
  296. new Data[124], len;
  297. new line = 0;
  298. new pos[12][8];
  299.  
  300. while(g_TotalSpawns < MAX_SPAWNS && (line = read_file(MapFile , line , Data , 123 , len) ) != 0 )
  301. {
  302. if (strlen(Data)<2 || Data[0] == '[')
  303. continue;
  304.  
  305. parse(Data, pos[1], 7, pos[2], 7, pos[3], 7, pos[4], 7, pos[5], 7, pos[6], 7, pos[7], 7, pos[8], 7, pos[9], 7, pos[10], 7);
  306.  
  307. // Origin
  308. g_SpawnVecs[g_TotalSpawns][0] = str_to_float(pos[1]);
  309. g_SpawnVecs[g_TotalSpawns][1] = str_to_float(pos[2]);
  310. g_SpawnVecs[g_TotalSpawns][2] = str_to_float(pos[3]);
  311.  
  312. //Angles
  313. g_SpawnAngles[g_TotalSpawns][0] = str_to_float(pos[4]);
  314. g_SpawnAngles[g_TotalSpawns][1] = str_to_float(pos[5]);
  315. g_SpawnAngles[g_TotalSpawns][2] = str_to_float(pos[6]);
  316.  
  317. //v-Angles
  318. g_SpawnVAngles[g_TotalSpawns][0] = str_to_float(pos[7]);
  319. g_SpawnVAngles[g_TotalSpawns][1] = str_to_float(pos[8]);
  320. g_SpawnVAngles[g_TotalSpawns][2] = str_to_float(pos[9]);
  321.  
  322. //Team - ignore
  323.  
  324. g_TotalSpawns++;
  325. }
  326.  
  327. log_amx("Loaded %d spawn points for map %s.", g_TotalSpawns, Map);
  328. } else {
  329. log_amx("No spawn points file found (%s)", MapFile);
  330. }
  331.  
  332. return 1;
  333. }
  334. public spawn_Preset(id)
  335. {
  336. if (g_TotalSpawns < 2)
  337. return PLUGIN_CONTINUE;
  338.  
  339. new list[MAX_SPAWNS];
  340. new num = 0;
  341. new final = -1;
  342. new total=0;
  343. new players[32], n, x = 0;
  344. new Float:loc[32][3], locnum;
  345.  
  346. //cache locations
  347. get_players(players, num);
  348. for (new i=0; i<num; i++)
  349. {
  350. if (is_user_alive(players[i]) && players[i] != id)
  351. {
  352. entity_get_vector(players[i], EV_VEC_origin, loc[locnum]);
  353. locnum++;
  354. }
  355. }
  356.  
  357. num = 0;
  358. while (num <= g_TotalSpawns)
  359. {
  360. //have we visited all the spawns yet?
  361. if (num == g_TotalSpawns)
  362. break;
  363. //get a random spawn
  364. n = random_num(0, g_TotalSpawns-1);
  365. //have we visited this spawn yet?
  366. if (!list[n])
  367. {
  368. //yes, set the flag to true, and inc the number of spawns we've visited
  369. list[n] = 1;
  370. num++;
  371. }
  372. else
  373. {
  374. //this was a useless loop, so add to the infinite loop prevention counter
  375. total++;
  376. if (total > 100) // don't search forever
  377. break;
  378. continue; //don't check again
  379. }
  380.  
  381. new trace = trace_hull(g_SpawnVecs[n],1);
  382. if (trace)
  383. continue;
  384.  
  385. if (locnum < 1)
  386. {
  387. final = n;
  388. break;
  389. }
  390.  
  391. final = n;
  392. for (x = 0; x < locnum; x++)
  393. {
  394. new Float:distance = get_distance_f(g_SpawnVecs[n], loc[x]);
  395. if (distance < 250.0)
  396. {
  397. //invalidate
  398. final = -1;
  399. break;
  400. }
  401. }
  402.  
  403. if (final != -1)
  404. break;
  405. }
  406.  
  407. if (final != -1)
  408. {
  409. entity_set_origin(id, g_SpawnVecs[final]);
  410. entity_set_int(id, EV_INT_fixangle, 1);
  411. entity_set_vector(id, EV_VEC_angles, g_SpawnAngles[final]);
  412. entity_set_vector(id, EV_VEC_v_angle, g_SpawnVAngles[final]);
  413. entity_set_int(id, EV_INT_fixangle, 1);
  414.  
  415. return PLUGIN_HANDLED;
  416. }
  417.  
  418. return PLUGIN_CONTINUE;
  419. }
  420. public fw_Think(iEnt){
  421. entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 1.0);
  422. if(get_pcvar_num(g_msg_enable)){
  423. static r, g, b, Float:x,Float:y;
  424. HudMsgPos(x,y);
  425. HudMsgColor(g_msg_color, r, g, b);
  426. formatex(message, charsmax(message), "%L", LANG_PLAYER, "DM_MESSAGE",((g_nightdm)?"N":"FF"), get_pcvar_num(cvar_start), get_pcvar_num(cvar_end));
  427. set_hudmessage(r, g, b, x, y, _, _, 1.0, _, _, 1);
  428. ShowSyncHudMsg(0, g_MsgSync1, message);
  429. }
  430. static hour_str[3],get_hour, get_start,get_end;
  431.  
  432. get_time("%H",hour_str,2);
  433.  
  434. get_hour = str_to_num(hour_str);
  435.  
  436. get_start = get_pcvar_num(cvar_start);
  437. get_end = get_pcvar_num(cvar_end);
  438.  
  439. if(get_start < get_end ? (get_start <= get_hour && get_hour < get_end) : (get_start <= get_hour || get_hour < get_end)) {
  440. g_nightdm = true;
  441. new szFlags[ 27 ];
  442. get_pcvar_string( g_change, szFlags, charsmax( szFlags ) );
  443.  
  444. if (containi(szFlags, "a") != -1){
  445. server_cmd("sv_skyname space");
  446. }
  447. if (containi(szFlags, "b") != -1){
  448. set_lights("d");
  449. }
  450. set_msg_block(get_user_msgid("RoundTime"), BLOCK_SET);
  451. set_msg_block(get_user_msgid("ShowTimer"), BLOCK_SET);
  452. g_restart2 = false;
  453. for (new i = 0; i < sizeof g_objective_ents; ++i) {
  454. RemoveEntity(g_objective_ents[i]);
  455. }
  456. restart();
  457. }else{
  458. g_nightdm = false;
  459. g_restart = false;
  460. new szFlags[ 27 ];
  461. get_pcvar_string( g_change, szFlags, charsmax( szFlags ) );
  462. if (containi(szFlags, "a") != -1){
  463. set_cvar_string("sv_skyname" , normalsky);
  464. }
  465. if (containi(szFlags, "b") != -1){
  466. set_lights("#OFF");
  467. }
  468. set_msg_block(get_user_msgid("RoundTime"), BLOCK_NOT);
  469. set_msg_block(get_user_msgid("ShowTimer"), BLOCK_NOT);
  470. for (new i = 0; i < sizeof g_objective_ents; ++i) {
  471. RestoreEntity(g_objective_ents[i]);
  472. }
  473. restart2();
  474. }
  475. }
  476. public FwdPlayerSpawnPost(id){
  477. if(g_nightdm){
  478. if(is_user_alive( id ) )
  479. {
  480. spawn_Preset(id);
  481. strip_user_weapons( id );
  482. give_item( id, "weapon_knife" );
  483. new szFlags[ 27 ];
  484. get_pcvar_string( g_grenades, szFlags, charsmax( szFlags ) );
  485.  
  486. if (containi(szFlags, "a") != -1){
  487. give_item( id, "weapon_hegrenade" );
  488. }
  489. if (containi(szFlags, "b") != -1){
  490. give_item( id, "weapon_smokegrenade" );
  491. }
  492. if (containi(szFlags, "c") != -1){
  493. give_item( id, "weapon_flashbang" );
  494. }
  495. cs_set_user_armor(id, get_pcvar_num(gCvarArmor), CS_ARMOR_VESTHELM);
  496. new hideflags = GetHudHideFlags();
  497. sp_off(id);
  498. set_task(0.2,"protect",id);
  499. if( g_bRememberGuns[ id ] ){
  500. PreviousWeapons(id);
  501. }else{
  502. GunsMenu(id);
  503. }
  504. if( hideflags )
  505. {
  506. message_begin( MSG_ONE, get_user_msgid( "HideWeapon" ), _, id );
  507. write_byte( hideflags );
  508. message_end();
  509. }
  510.  
  511. }
  512. }
  513. }
  514. public msg_hideweapon(){
  515. if(g_nightdm){
  516. new hideflags = GetHudHideFlags();
  517.  
  518. if( hideflags )
  519. set_msg_arg_int( 1, ARG_BYTE, get_msg_arg_int( 1 ) | hideflags );
  520. }
  521. }
  522. GetHudHideFlags(){
  523. new iFlags;
  524.  
  525. iFlags |= HUD_HIDE_MONEY;
  526. iFlags |= HUD_HIDE_TIMER;
  527.  
  528. return iFlags;
  529. }
  530. public client_putinserver(id){
  531. g_bRememberGuns[ id ] = false;
  532. g_iPrimaryWeapon[ id ] = 0;
  533. g_iSecondaryWeapon[ id ] = 0;
  534. }
  535. public client_disconnect(id){
  536. remove_task(id);
  537. sp_off(id);
  538. return PLUGIN_HANDLED;
  539. }
  540. public join_team()
  541. {
  542. if(g_nightdm)
  543. {
  544. new Client = read_data(1);
  545. static user_team[32];
  546.  
  547. read_data(2, user_team, 31);
  548.  
  549. if(!is_user_connected(Client))
  550. return PLUGIN_HANDLED;
  551.  
  552. switch(user_team[0])
  553. {
  554. case 'C':
  555. {
  556. if(!is_user_alive(Client))
  557. set_task(1.0,"spawnning",Client);
  558. }
  559.  
  560. case 'T':
  561. {
  562. if(!is_user_alive(Client))
  563. set_task(1.0,"spawnning",Client);
  564. }
  565.  
  566. case 'S':
  567. {
  568. ClientPrintColor(Client, "!g[%s] %L", Prefix , LANG_PLAYER, "DM_SPEC");
  569. }
  570. }
  571. }
  572. return 0;
  573. }
  574. public spawnning(Client) {
  575. ExecuteHamB(Ham_CS_RoundRespawn, Client);
  576. ClientPrintColor(Client, "!g[%s] %L", Prefix , LANG_PLAYER, "DM_RASP");
  577. ClientPrintColor(Client, "!g[%s] %s v%s, Copyright (C) 2015 by %s",Prefix, PLUGIN, VERSION, AUTHOR);
  578. remove_task(Client);
  579. }
  580. public PlayerKilled(Victim){
  581. if (!is_user_alive(Victim))
  582. set_task(1.0, "PlayerRespawn", Victim);
  583. }
  584. public PlayerRespawn(id){
  585. if(g_nightdm){
  586. if (!is_user_alive(id) && CS_TEAM_T <= cs_get_user_team(id) <= CS_TEAM_CT )
  587. {
  588. ExecuteHamB(Ham_CS_RoundRespawn, id);
  589. }
  590. }
  591. }
  592. public restart(){
  593. if (g_restart){
  594. return PLUGIN_HANDLED;
  595. }else{
  596. g_restart = true;
  597. server_cmd("sv_restart 1");
  598. ClientPrintColor(0, "!g[%s] %L", Prefix , LANG_PLAYER, "DM_MODS");
  599. }
  600. return PLUGIN_HANDLED;
  601. }
  602. public restart2(){
  603. if (g_restart2){
  604. return PLUGIN_HANDLED;
  605. }else{
  606. g_restart2 = true;
  607. server_cmd("sv_restart 1");
  608. ClientPrintColor(0, "!g[%s] %L", Prefix , LANG_PLAYER, "DM_MODE");
  609. }
  610. return PLUGIN_HANDLED;
  611. }
  612. public Message_StatusIcon(iMsgId, iMsgDest,id)
  613. {
  614. if(g_nightdm){
  615. static szIcon[8];
  616. get_msg_arg_string(2, szIcon, charsmax(szIcon));
  617. if(equal(szIcon, "buyzone"))
  618. {
  619. if(get_msg_arg_int(1))
  620. {
  621. set_pdata_int(id, 235, get_pdata_int(id, 235) & ~(1<<0));
  622. return PLUGIN_HANDLED;
  623. }
  624. }
  625. }
  626.  
  627. return PLUGIN_CONTINUE;
  628. }
  629. public WeaponBox_Touch ( const WeaponBox, const Other ){
  630. if(g_nightdm){
  631. if ( !Other || Other > gMaxClients )
  632. {
  633. set_pev( WeaponBox, pev_nextthink, get_gametime() + get_pcvar_float( pCvarTime ) );
  634. }
  635. }
  636. }
  637. public curweapon(id) {
  638. if(g_nightdm){
  639. new iWeapon = read_data(2);
  640.  
  641. if(g_WeaponSlots[iWeapon] == 1 || g_WeaponSlots[iWeapon] == 2)
  642. {
  643. if(cs_get_user_bpammo(id, iWeapon) < g_WeaponBPAmmo[iWeapon])
  644. {
  645. cs_set_user_bpammo(id, iWeapon, g_WeaponBPAmmo[iWeapon]);
  646. }
  647. }
  648. return PLUGIN_CONTINUE;
  649. }
  650. return PLUGIN_CONTINUE;
  651. }
  652. public protect(id) {
  653. new SPSecs = get_pcvar_num(cvar_time);
  654. set_user_godmode(id, 1);
  655.  
  656. switch(cs_get_user_team( id )){
  657. case CS_TEAM_CT:{
  658. set_user_rendering(id, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25);
  659. }
  660. case CS_TEAM_T:{
  661. set_user_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25);
  662. }
  663. }
  664. set_hudmessage(255, 1, 1, -1.0, -1.0, 0, 6.0, get_pcvar_float(cvar_time), 0.1, 0.2, 4);
  665. ShowSyncHudMsg(id, g_MsgSync2, "%L", LANG_PLAYER, "DM_PROTECT", SPSecs);
  666.  
  667. set_task(get_pcvar_float(cvar_time), "sp_off", id);
  668. return PLUGIN_HANDLED;
  669. }
  670. public sp_off(id) {
  671. if(is_user_alive(id))
  672. {
  673. set_user_godmode(id, 0);
  674. set_user_rendering(id, kRenderFxGlowShell, 0, 0,0, kRenderNormal, 25);
  675. }
  676. return PLUGIN_HANDLED;
  677. }
  678. public CmdGunsEnable( id )
  679. {
  680. if( g_bRememberGuns[ id ] )
  681. {
  682. ClientPrintColor(id, "!g[%s] %L", Prefix, LANG_PLAYER, "DM_GUN");
  683. g_bRememberGuns[ id ] = false;
  684. }
  685.  
  686. else
  687. ClientPrintColor(id, "!g[%s] %L", Prefix, LANG_PLAYER, "DM_GUN2");
  688. }
  689. public GunsMenu(id)
  690. {
  691. new itemmenu[64];
  692. formatex(itemmenu, charsmax(itemmenu), "\r%L\w", LANG_PLAYER, "DM_TITLE");
  693. g_hWeaponMenu = menu_create(itemmenu , "WeaponMainMenu_Handler" );
  694. formatex(itemmenu, charsmax(itemmenu), "%L", LANG_PLAYER, "DM_ITEM");
  695. menu_additem( g_hWeaponMenu, itemmenu, "0" );
  696. formatex(itemmenu, charsmax(itemmenu), "%L", LANG_PLAYER, "DM_ITEM2");
  697. menu_additem( g_hWeaponMenu, itemmenu, "1" );
  698. formatex(itemmenu, charsmax(itemmenu), "%L", LANG_PLAYER, "DM_ITEM3");
  699. menu_additem( g_hWeaponMenu, itemmenu, "2" );
  700. menu_setprop(g_hWeaponMenu , MPROP_EXIT , MEXIT_NEVER);
  701. menu_display( id,g_hWeaponMenu, 0 );
  702. }
  703. public WeaponMainMenu_Handler( id, hMenu, iItem )
  704. {
  705. switch( iItem )
  706. {
  707. case 0: menu_display( id,g_hPrimaryWeaponMenu, 0 );
  708. case 1:
  709. {
  710. PreviousWeapons(id);
  711. }
  712.  
  713. case 2:
  714. {
  715. PreviousWeapons(id);
  716. g_bRememberGuns[ id ] = true;
  717. ClientPrintColor(id, "!g[%s] %L", Prefix, LANG_PLAYER, "DM_GUNS");
  718. }
  719. }
  720. }
  721. public PreviousWeapons(id)
  722. {
  723. new szpData[32], szsData[32];
  724. ArrayGetString(g_PrimaryWeapons, g_iPrimaryWeapon[id], szpData, charsmax(szpData));
  725. ArrayGetString(g_SecondaryWeapons, g_iSecondaryWeapon[id], szsData, charsmax(szsData));
  726. strtolower(szpData);
  727. strtolower(szsData);
  728. replace_all(szpData, charsmax(szpData), " ", "");
  729. replace_all(szsData, charsmax(szsData), " ", "");
  730. format(szpData, charsmax(szpData), "weapon_%s", szpData);
  731. format(szsData, charsmax(szsData), "weapon_%s", szsData);
  732. GiveWeapons(id, szpData);
  733. GiveWeapons(id, szsData);
  734. }
  735.  
  736. public CreateWeaponsArray()
  737. {
  738. get_configsdir(g_szWepFile, charsmax(g_szWepFile)); //gets addons/amxmodx/configs directory
  739. format(g_szWepFile, charsmax(g_szWepFile), "%s/NightDM_Weapon.ini", g_szWepFile); //formats the file name for the Weapons order INI
  740. g_FilePointer = fopen(g_szWepFile, "r");
  741.  
  742. g_PrimaryWeapons = ArrayCreate(15);
  743. g_SecondaryWeapons = ArrayCreate(15);
  744.  
  745.  
  746. new itemmenu[64];
  747. formatex(itemmenu, charsmax(itemmenu), "\r%L\w", LANG_PLAYER, "DM_TITLE2");
  748. g_hPrimaryWeaponMenu = menu_create( itemmenu, "PrimaryWeapons_Handler" );
  749. formatex(itemmenu, charsmax(itemmenu), "\r%L\w", LANG_PLAYER, "DM_TITLE3");
  750. g_hSecondaryWeaponMenu = menu_create( itemmenu, "SecondaryWeapons_Handler" );
  751.  
  752. new szData[32], szWeaponName[32], szpNum[3], szsNum[3];
  753. new pCounter, sCounter;
  754. if(g_FilePointer)
  755. {
  756. while(!feof(g_FilePointer))
  757. {
  758. fgets(g_FilePointer, szData, charsmax(szData));
  759. trim(szData);
  760. if(containi(szData, ";") != -1)
  761. continue;
  762.  
  763. copy(szWeaponName, charsmax(szWeaponName), szData);
  764. replace_all(szWeaponName, charsmax(szWeaponName), " ", "");
  765. format(szWeaponName, charsmax(szWeaponName), "weapon_%s", szWeaponName);
  766. strtolower(szWeaponName);
  767. new iWeaponID = get_weaponid(szWeaponName);
  768.  
  769. switch(g_WeaponSlots[iWeaponID])
  770. {
  771. case 1:
  772. {
  773. ArrayPushString(g_PrimaryWeapons, szData);
  774. num_to_str(pCounter, szpNum, charsmax(szpNum));
  775. menu_additem(g_hPrimaryWeaponMenu, szData, szpNum, 0);
  776. ++pCounter;
  777. }
  778. case 2:
  779. {
  780. ArrayPushString(g_SecondaryWeapons, szData);
  781. num_to_str(sCounter, szsNum, charsmax(szsNum));
  782. menu_additem(g_hSecondaryWeaponMenu, szData, szsNum, 0);
  783. ++sCounter;
  784. }
  785. }
  786. }
  787. }
  788. else
  789. {
  790. set_fail_state("Failed to Open Weapons List");
  791. }
  792. menu_setprop(g_hPrimaryWeaponMenu , MPROP_EXIT , MEXIT_NEVER);
  793. menu_setprop(g_hSecondaryWeaponMenu , MPROP_EXIT , MEXIT_NEVER);
  794.  
  795. fclose(g_FilePointer);
  796. }
  797.  
  798. public PrimaryWeapons_Handler(id, iMenu, iItem)
  799. {
  800. new szKey[3], iSelectedWeapon, Dummy;
  801. menu_item_getinfo(iMenu, iItem, Dummy, szKey, 2, "", 0, Dummy);
  802.  
  803. iSelectedWeapon = str_to_num(szKey);
  804. g_iPrimaryWeapon[id] = iSelectedWeapon;
  805.  
  806. new WeaponName[32], szArrayData[32];
  807. ArrayGetString(g_PrimaryWeapons, iSelectedWeapon, szArrayData, charsmax(szArrayData));
  808. replace_all(szArrayData, charsmax(szArrayData), " ", "");
  809. format(WeaponName, charsmax(WeaponName), "weapon_%s", szArrayData);
  810. strtolower(WeaponName);
  811. GiveWeapons(id, WeaponName);
  812.  
  813. menu_display(id, g_hSecondaryWeaponMenu);
  814. }
  815.  
  816. public SecondaryWeapons_Handler(id, iMenu, iItem)
  817. {
  818. new szKey[3], iSelectedWeapon, Dummy;
  819. menu_item_getinfo(iMenu, iItem, Dummy, szKey, 2, "", 0, Dummy);
  820.  
  821. iSelectedWeapon = str_to_num(szKey);
  822. g_iSecondaryWeapon[id] = iSelectedWeapon;
  823.  
  824. new WeaponName[32], szArrayData[32];
  825. ArrayGetString(g_SecondaryWeapons, iSelectedWeapon, szArrayData, charsmax(szArrayData));
  826. replace_all(szArrayData, charsmax(szArrayData), " ", "");
  827. format(WeaponName, charsmax(WeaponName), "weapon_%s", szArrayData);
  828. strtolower(WeaponName);
  829. GiveWeapons(id, WeaponName);
  830. }
  831. public eDeathMsg() {
  832. if(g_nightdm){
  833. new KillerId = read_data(1);
  834. new VictimId = read_data(2);
  835. if(!KillerId || KillerId > gMaxClients)
  836. return;
  837.  
  838. if(KillerId == VictimId || get_user_team(KillerId) == get_user_team(VictimId))
  839. return;
  840.  
  841. new KillerHealth = get_user_health(KillerId);
  842. new NewKillerHealth = min( ( read_data(3) ?
  843. get_pcvar_num(health_hs_add) :
  844. get_pcvar_num(health_add) ) +
  845. KillerHealth ,
  846.  
  847. get_pcvar_num(health_max));
  848.  
  849. set_user_health(KillerId, NewKillerHealth);
  850.  
  851. set_hudmessage(0, 255, 0, -1.0, 0.15, 0, 1.0, 1.0, 0.1, 0.1, -1);
  852. ShowSyncHudMsg(KillerId, g_MsgSync3,"Healed +%d hp", NewKillerHealth - KillerHealth);
  853.  
  854. message_begin(MSG_ONE, gmsgScreenFade, _, KillerId);
  855. write_short(1<<10);
  856. write_short(1<<10);
  857. write_short(0x0000);
  858. write_byte(0);
  859. write_byte(0);
  860. write_byte(200);
  861. write_byte(75);
  862. message_end();
  863. }
  864. }
  865. RemoveEntity( const szClassName[ ] ){
  866. new szFakeClassName[ 32 ];
  867. GetFakeClassName( szClassName, szFakeClassName, charsmax( szFakeClassName ) );
  868.  
  869. new iEntity = -1;
  870. while( ( iEntity = find_ent_by_class( iEntity, szClassName ) ) )
  871. {
  872. entity_set_string( iEntity, EV_SZ_classname, szFakeClassName );
  873. }
  874. }
  875.  
  876. RestoreEntity( const szClassName[ ] ){
  877. new szFakeClassName[ 32 ];
  878. GetFakeClassName( szClassName, szFakeClassName, charsmax( szFakeClassName ) );
  879.  
  880. new iEntity = -1;
  881. while( ( iEntity = find_ent_by_class( iEntity, szFakeClassName ) ) )
  882. {
  883. entity_set_string( iEntity, EV_SZ_classname, szClassName );
  884. }
  885. }
  886.  
  887. GetFakeClassName( const szClassName[ ], szFakeClassName[ ], const iLen ){
  888. formatex( szFakeClassName, iLen, "___%s", szClassName );
  889. }
  890. stock GiveWeapons(id, szWeapon[])
  891. {
  892. if(is_user_connected(id))
  893. {
  894. new iWeaponId = get_weaponid(szWeapon);
  895. give_item(id, szWeapon);
  896. cs_set_user_bpammo(id, iWeaponId, g_WeaponBPAmmo[iWeaponId]);
  897. }
  898. }
  899. public HudMsgColor(cvar, &r, &g, &b)
  900. {
  901. static color[16], piece[5];
  902. get_pcvar_string(cvar, color, 15);
  903.  
  904. strbreak( color, piece, 4, color, 15);
  905. r = str_to_num(piece);
  906.  
  907. strbreak( color, piece, 4, color, 15);
  908. g = str_to_num(piece);
  909. b = str_to_num(color);
  910. }
  911.  
  912. public HudMsgPos(&Float:x, &Float:y)
  913. {
  914. static coords[16], piece[10];
  915. get_pcvar_string(g_msg_xypos, coords, 15);
  916.  
  917. strbreak(coords, piece, 9, coords, 15);
  918. x = str_to_float(piece);
  919. y = str_to_float(coords);
  920. }
  921. ClientPrintColor( id, String[ ], any:... ){
  922. new szMsg[ 190 ];
  923. vformat( szMsg, charsmax( szMsg ), String, 3 );
  924.  
  925. replace_all( szMsg, charsmax( szMsg ), "!n", "^1" );
  926. replace_all( szMsg, charsmax( szMsg ), "!t", "^3" );
  927. replace_all( szMsg, charsmax( szMsg ), "!g", "^4" );
  928.  
  929. static msgSayText = 0;
  930. static fake_user;
  931.  
  932. if( !msgSayText )
  933. {
  934. msgSayText = get_user_msgid( "SayText" );
  935. fake_user = get_maxplayers( ) + 1;
  936. }
  937.  
  938. message_begin( id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgSayText, _, id );
  939. write_byte( id ? id : fake_user );
  940. write_string( szMsg );
  941. message_end( );
  942. }
  943. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  944. *{\\ rtf1\\ ansi\\ ansicpg1252\\ deff0\\ deflang1033{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
  945. */
  946.