HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /**
  2.  *
  3.  * Custom Sniper Scopes
  4.  * by Numb
  5.  *
  6.  *
  7.  * Description:
  8.  * This plugin changes sniper scopes to custom ones. Client still has the ability to disable
  9.  * custom scopes by typing "/scope" in chat. That command will open a menu which allows client
  10.  * to choose what sniper rifles will have custom scopes and which ones wont. Admins can change
  11.  * scopes by using available cvars. Cvars can be changed to a sprite name without the ".spr"
  12.  * ending, and without the "sprites/" folder at the beginning. An example of cvar string for
  13.  * custom scope (using the default sprite) would be "sniper_scope".
  14.  *
  15.  *
  16.  * Requires:
  17.  * FakeMeta
  18.  * HamSandWich
  19.  *
  20.  *
  21.  * Cvars:
  22.  *
  23.  * + "[U]scope_awp[/U]" - "" - awp custom scope.
  24.  * + "[U]scope_scout[/U]" - "" - scout custom scope.
  25.  * + "[U]scope_g3sg1[/U]" - "" - g3sg1 custom scope.
  26.  * + "[U]scope_sg550[/U]" - "" - sg550 custom scope.
  27.  *
  28.  *
  29.  * Additional Info:
  30.  * Tested in Counter-Strike 1.6 with amxmodx 1.8.2 (dev build hg21). Leaving the cvars empty
  31.  * will enforce the scopes what are uploaded with the plugin.
  32.  *
  33.  *
  34.  * Notes:
  35.  * Cvar changes take effect only at mapchange. And in order for sprites not to repeat, plugin
  36.  * will copy them to a different name what shall be unique only to your server ip. However
  37.  * don't remove your non-copied ones.
  38.  *
  39.  *
  40.  * Warnings:
  41.  * Pausing and/or unpausing this plugin within an event (from message_begin() to message_end())
  42.  * may result in an error and possible crash.
  43.  *
  44.  *
  45.  * Images:
  46.  *
  47.  * + AWP: http://cloud-2.steampowered.com/ugc/542933952325064122/CBF6A12159853071F6A85D0F206098CA339BEEA2/
  48.  * + Scout: http://cloud.steampowered.com/ugc/542933952325068238/91655CC6CD11E7AC3D62ACAB634DB968551794B1/
  49.  * + G3SG1: http://cloud.steampowered.com/ugc/542933952325075179/AFD1098BC1177B6545D7E40D342B4D9BCB3120F6/
  50.  * + SG550: http://cloud-2.steampowered.com/ugc/542933952325077902/7380A6F6034E6364FC28BE47727E8E887A0A0077/
  51.  *
  52.  *
  53.  * Credits:
  54.  * Special thanks to Arkshine ( http://forums.alliedmods.net/member.php?u=7779 ) for help in
  55.  * WeaponList ( http://forums.alliedmods.net/showthread.php?t=175632 ) related things.
  56.  *
  57.  *
  58.  * ChangeLog:
  59.  *
  60.  *
  61.  * + 1.1
  62.  * - Changed: Advertisement isn't that often.
  63.  * - Changed: Advertisement is higher up the screen.
  64.  *
  65.  * + 1.0
  66.  * - First release.
  67.  *
  68.  *
  69.  * Downloads:
  70.  * Amx Mod X forums: http://forums.alliedmods.net/showthread.php?p=1761329#post1761329
  71.  *
  72. **/
  73.  
  74.  
  75. #include <amxmodx>
  76. #include <fakemeta>
  77. #include <hamsandwich>
  78.  
  79. #define PLUGIN_NAME "Custom Sniper Scopes"
  80. #define PLUGIN_VERSION "1.1"
  81. #define PLUGIN_AUTHOR "Numb"
  82.  
  83. #define SetPlayerBit(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) )
  84. #define ClearPlayerBit(%1,%2) ( %1 &= ~( 1 << ( %2 & 31 ) ) )
  85. #define CheckPlayerBit(%1,%2) ( %1 & ( 1 << ( %2 & 31 ) ) )
  86.  
  87. #define m_pPlayer 41
  88. #define m_iId 43
  89. #define m_iClip 51
  90.  
  91. #define m_pActiveItem 373
  92.  
  93. new g_iAWPFileName[64];
  94. new g_iScoutFileName[64];
  95. new g_iG3SG1FileName[64];
  96. new g_iSG550FileName[64];
  97.  
  98. new g_iCustomAwp;
  99. new g_iCustomScout;
  100. new g_iCustomG3SG1;
  101. new g_iCustomSG550;
  102. new g_iShouldUpdate;
  103.  
  104. new g_iLastSpectated[33];
  105.  
  106. new g_iMsgId_CurWeapon;
  107. new g_iMsgId_WeaponList;
  108.  
  109.  
  110. public plugin_precache()
  111. {
  112. new iIpAddress[16];
  113. get_user_ip(0, iIpAddress, 15, 1);
  114. replace_all(iIpAddress, 15, ".", "_");
  115.  
  116. #define AWP_CONFIG "14^n\
  117. weapon 320 320hud1 80 120 80 20^n\
  118. weapon_s 320 320hud1 80 140 80 20^n\
  119. ammo 320 640hud7 24 96 24 24^n\
  120. %s^n\
  121. weapon 640 640hud2 0 135 170 45^n\
  122. weapon_s 640 640hud5 0 135 170 45^n\
  123. ammo 640 640hud7 24 96 24 24^n\
  124. %s"
  125. if( configurate(register_cvar("scope_awp", ""), "awp", AWP_CONFIG, iIpAddress, g_iAWPFileName, 63) )
  126. register_clcmd(g_iAWPFileName, "clcmd_fix_awp");
  127.  
  128. #define SCOUT_CONFIG "14^n\
  129. weapon 320 320hud1 0 80 80 20^n\
  130. weapon_s 320 320hud1 0 100 80 20^n\
  131. ammo 320 640hud7 72 72 24 24^n\
  132. %s^n\
  133. weapon 640 640hud12 0 45 170 45^n\
  134. weapon_s 640 640hud13 0 45 170 45^n\
  135. ammo 640 640hud7 72 72 24 24^n\
  136. %s"
  137. if( configurate(register_cvar("scope_scout", ""), "scout", SCOUT_CONFIG, iIpAddress, g_iScoutFileName, 63) )
  138. register_clcmd(g_iScoutFileName, "clcmd_fix_scout");
  139.  
  140. #define G3SG1_CONFIG "14^n\
  141. weapon 320 320hud1 80 160 80 20^n\
  142. weapon_s 320 320hud1 80 180 80 20^n\
  143. ammo 320 640hud7 72 72 24 24^n\
  144. %s^n\
  145. weapon 640 640hud2 0 180 170 45^n\
  146. weapon_s 640 640hud5 0 180 170 45^n\
  147. ammo 640 640hud7 72 72 24 24^n\
  148. %s"
  149. if( configurate(register_cvar("scope_g3sg1", ""), "g3sg1", G3SG1_CONFIG, iIpAddress, g_iG3SG1FileName, 63) )
  150. register_clcmd(g_iG3SG1FileName, "clcmd_fix_g3sg1");
  151.  
  152. #define SG550_CONFIG "14^n\
  153. weapon 320 320hud2 160 168 80 20^n\
  154. weapon_s 320 320hud2 160 188 80 20^n\
  155. ammo 320 640hud7 0 96 24 24^n\
  156. %s^n\
  157. weapon 640 640hud14 0 180 170 45^n\
  158. weapon_s 640 640hud15 0 180 170 45^n\
  159. ammo 640 640hud7 0 96 24 24^n\
  160. %s"
  161. if( configurate(register_cvar("scope_sg550", ""), "sg550", SG550_CONFIG, iIpAddress, g_iSG550FileName, 63) )
  162. register_clcmd(g_iSG550FileName, "clcmd_fix_sg550");
  163. }
  164.  
  165. public plugin_init()
  166. {
  167. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  168.  
  169. register_event("TextMsg", "Event_ResetInfo", "bd", "1=4", "2=#Spec_Mode1"); // Locked Chase Cam
  170. register_event("TextMsg", "Event_ResetInfo", "bd", "1=4", "2=#Spec_Mode2"); // Free Chase Cam
  171. register_event("TextMsg", "Event_ResetInfo", "bd", "1=4", "2=#Spec_Mode3"); // Free Look
  172. register_event("TextMsg", "Event_ResetInfo", "bd", "1=4", "2=#Spec_Mode5"); // Free Overview
  173. register_event("TextMsg", "Event_ResetInfo", "bd", "1=4", "2=#Spec_Mode6"); // Chase Overview
  174. register_event("ResetHUD", "Event_ResetInfo", "be");
  175.  
  176. register_message((g_iMsgId_CurWeapon=get_user_msgid("CurWeapon")), "Message_CurWeapon");
  177.  
  178. register_menucmd(register_menuid("Custom Scopes"), 1023, "Menu_Select_Scopes");
  179.  
  180. register_clcmd("say /tavcso", "clcmd_scope", ADMIN_USER, " - menu to change your sniper scopes");
  181.  
  182. if( g_iAWPFileName[0] )
  183. RegisterHam(Ham_Item_AttachToPlayer, "weapon_awp", "Ham_AttachToPlayer_Post", 1);
  184. if( g_iScoutFileName[0] )
  185. RegisterHam(Ham_Item_AttachToPlayer, "weapon_scout", "Ham_AttachToPlayer_Post", 1);
  186. if( g_iG3SG1FileName[0] )
  187. RegisterHam(Ham_Item_AttachToPlayer, "weapon_g3sg1", "Ham_AttachToPlayer_Post", 1);
  188. if( g_iSG550FileName[0] )
  189. RegisterHam(Ham_Item_AttachToPlayer, "weapon_sg550", "Ham_AttachToPlayer_Post", 1);
  190.  
  191. g_iMsgId_WeaponList = get_user_msgid("WeaponList");
  192. }
  193.  
  194. public plugin_pause()
  195. {
  196. new iPlayers[32], iPlayerNum, iPlrId;
  197. get_players(iPlayers, iPlayerNum, "ch");
  198. for( new iPlayer; iPlayer<iPlayerNum; iPlayer++ )
  199. {
  200. iPlrId = iPlayers[iPlayer];
  201.  
  202. if( CheckPlayerBit(g_iShouldUpdate, iPlrId) )
  203. continue;
  204.  
  205. if( CheckPlayerBit(g_iCustomAwp, iPlrId) )
  206. send_awp(iPlrId, true);
  207. if( CheckPlayerBit(g_iCustomScout, iPlrId) )
  208. send_scout(iPlrId, true);
  209. if( CheckPlayerBit(g_iCustomG3SG1, iPlrId) )
  210. send_g3sg1(iPlrId, true);
  211. if( CheckPlayerBit(g_iCustomSG550, iPlrId) )
  212. send_sg550(iPlrId, true);
  213. }
  214. g_iCustomAwp = 0;
  215. g_iCustomScout = 0;
  216. g_iCustomG3SG1 = 0;
  217. g_iCustomSG550 = 0;
  218. g_iShouldUpdate = 0;
  219. }
  220.  
  221. public plugin_unpause()
  222. {
  223. new iPlayers[32], iPlayerNum, iPlrId;
  224. get_players(iPlayers, iPlayerNum, "ch");
  225. for( new iPlayer; iPlayer<iPlayerNum; iPlayer++ )
  226. {
  227. iPlrId = iPlayers[iPlayer];
  228.  
  229. send_awp(iPlrId);
  230. send_scout(iPlrId);
  231. send_g3sg1(iPlrId);
  232. send_sg550(iPlrId);
  233.  
  234. g_iLastSpectated[iPlrId] = 0;
  235. }
  236. }
  237.  
  238. public client_putinserver(iPlrId)
  239. {
  240. if( !is_user_hltv(iPlrId) && !is_user_bot(iPlrId) )
  241. {
  242. SetPlayerBit(g_iCustomAwp, iPlrId);
  243. SetPlayerBit(g_iCustomScout, iPlrId);
  244. SetPlayerBit(g_iCustomG3SG1, iPlrId);
  245. SetPlayerBit(g_iCustomSG550, iPlrId);
  246. SetPlayerBit(g_iShouldUpdate, iPlrId);
  247. }
  248.  
  249. g_iLastSpectated[iPlrId] = 0;
  250. }
  251.  
  252. public client_disconnect(iPlrId)
  253. {
  254. ClearPlayerBit(g_iCustomAwp, iPlrId);
  255. ClearPlayerBit(g_iCustomScout, iPlrId);
  256. ClearPlayerBit(g_iCustomG3SG1, iPlrId);
  257. ClearPlayerBit(g_iCustomSG550, iPlrId);
  258. ClearPlayerBit(g_iShouldUpdate, iPlrId);
  259.  
  260. g_iLastSpectated[iPlrId] = 0;
  261. }
  262.  
  263. public Event_ResetInfo(iPlrId)
  264. g_iLastSpectated[iPlrId] = 0;
  265.  
  266. public Message_CurWeapon(iMsgId, iMsgType, iPlrId)
  267. {
  268. if( CheckPlayerBit(g_iShouldUpdate, iPlrId) )
  269. {
  270. ClearPlayerBit(g_iShouldUpdate, iPlrId);
  271.  
  272. send_awp(iPlrId, false, false);
  273. send_scout(iPlrId, false, false);
  274. send_g3sg1(iPlrId, false, false);
  275. send_sg550(iPlrId, false, false);
  276. }
  277.  
  278. if( get_msg_arg_int(1) )
  279. {
  280. static s_iSpectated;
  281. s_iSpectated = pev(iPlrId, pev_iuser2);
  282. switch( get_msg_arg_int(2) )
  283. {
  284. case CSW_AWP:
  285. {
  286. if( g_iAWPFileName[0] && s_iSpectated!=g_iLastSpectated[iPlrId] )
  287. {
  288. g_iLastSpectated[iPlrId] = s_iSpectated;
  289. print_message(iPlrId);
  290. }
  291. }
  292. case CSW_SCOUT:
  293. {
  294. if( g_iScoutFileName[0] && s_iSpectated!=g_iLastSpectated[iPlrId] )
  295. {
  296. g_iLastSpectated[iPlrId] = s_iSpectated;
  297. print_message(iPlrId);
  298. }
  299. }
  300. case CSW_G3SG1:
  301. {
  302. if( g_iG3SG1FileName[0] && s_iSpectated!=g_iLastSpectated[iPlrId] )
  303. {
  304. g_iLastSpectated[iPlrId] = s_iSpectated;
  305. print_message(iPlrId);
  306. }
  307. }
  308. case CSW_SG550:
  309. {
  310. if( g_iAWPFileName[0] && s_iSpectated!=g_iLastSpectated[iPlrId] )
  311. {
  312. g_iLastSpectated[iPlrId] = s_iSpectated;
  313. print_message(iPlrId);
  314. }
  315. }
  316. default:
  317. {
  318. if( s_iSpectated!=g_iLastSpectated[iPlrId] )
  319. g_iLastSpectated[iPlrId] = 0;
  320. }
  321. }
  322. }
  323. }
  324.  
  325. public clcmd_fix_awp(iPlrId)
  326. {
  327. if( CheckPlayerBit(g_iCustomAwp, iPlrId) && !CheckPlayerBit(g_iShouldUpdate, iPlrId) )
  328. engclient_cmd(iPlrId, "weapon_awp");
  329. }
  330.  
  331. public clcmd_fix_scout(iPlrId)
  332. {
  333. if( CheckPlayerBit(g_iCustomScout, iPlrId) && !CheckPlayerBit(g_iShouldUpdate, iPlrId) )
  334. engclient_cmd(iPlrId, "weapon_scout");
  335. }
  336.  
  337. public clcmd_fix_g3sg1(iPlrId)
  338. {
  339. if( CheckPlayerBit(g_iCustomG3SG1, iPlrId) && !CheckPlayerBit(g_iShouldUpdate, iPlrId) )
  340. engclient_cmd(iPlrId, "weapon_g3sg1");
  341. }
  342.  
  343. public clcmd_fix_sg550(iPlrId)
  344. {
  345. if( CheckPlayerBit(g_iCustomSG550, iPlrId) && !CheckPlayerBit(g_iShouldUpdate, iPlrId) )
  346. engclient_cmd(iPlrId, "weapon_sg550");
  347. }
  348.  
  349. public clcmd_scope(iPlrId)
  350. {
  351. if( CheckPlayerBit(g_iShouldUpdate, iPlrId) )
  352. {
  353. ClearPlayerBit(g_iShouldUpdate, iPlrId);
  354.  
  355. send_awp(iPlrId, false, false);
  356. send_scout(iPlrId, false, false);
  357. send_g3sg1(iPlrId, false, false);
  358. send_sg550(iPlrId, false, false);
  359. }
  360.  
  361. Menu_Open_Scope(iPlrId);
  362. }
  363.  
  364. public Menu_Select_Scopes(iPlrId, iKey)
  365. {
  366. switch( iKey )
  367. {
  368. case 0: send_awp(iPlrId, (CheckPlayerBit(g_iCustomAwp, iPlrId)?true:false));
  369. case 1: send_scout(iPlrId, (CheckPlayerBit(g_iCustomScout, iPlrId)?true:false));
  370. case 2: send_g3sg1(iPlrId, (CheckPlayerBit(g_iCustomG3SG1, iPlrId)?true:false));
  371. case 3: send_sg550(iPlrId, (CheckPlayerBit(g_iCustomSG550, iPlrId)?true:false));
  372. default: return PLUGIN_HANDLED;
  373. }
  374. Menu_Open_Scope(iPlrId);
  375.  
  376. return PLUGIN_HANDLED;
  377. }
  378.  
  379. public Ham_AttachToPlayer_Post(iEnt, iPlrId)
  380. print_message(iPlrId);
  381.  
  382. configurate(iCvarPointer, const iWpnName[], const iWpnBuffer[], const iIpAddress[], iToggleCmd[], iLen)
  383. {
  384. #define IDENTICAL_320 "crosshair 320 crosshairs 24 0 24 24^n\
  385. autoaim 320 crosshairs 0 72 24 24^n\
  386. zoom 320 ch_sniper2 0 0 256 256^n\
  387. zoom_autoaim 320 ch_sniper2 0 0 256 256"
  388. #define IDENTICAL_640 "crosshair 640 crosshairs 24 0 24 24^n\
  389. autoaim 640 crosshairs 0 72 24 24^n\
  390. zoom 640 %s 0 0 256 256^n\
  391. zoom_autoaim 640 %s 0 0 256 256"
  392.  
  393. new iCvarText[32], iSpriteFile[64], bool:bFound;
  394.  
  395. if( get_pcvar_string(iCvarPointer, iCvarText, 31) )
  396. bFound = true;
  397. else
  398. formatex(iCvarText, 31, "scope_%s_numb", iWpnName);
  399.  
  400. formatex(iSpriteFile, 63, "sprites/%s.spr", iCvarText);
  401. if( file_exists(iSpriteFile) )
  402. {
  403. if( bFound )
  404. {
  405. new iSprite[64];
  406.  
  407. formatex(iSprite, 63, "sprites/%s_%s.spr", iCvarText, iIpAddress);
  408. if( !file_exists(iSprite) )
  409. {
  410. new iFileIdRead = fopen(iSpriteFile, "rb");
  411. if( !iFileIdRead )
  412. bFound = false;
  413. else
  414. {
  415. new iFileIdWrite = fopen(iSprite, "wb");
  416. if( !iFileIdWrite )
  417. {
  418. fclose(iFileIdRead);
  419. bFound = false;
  420. }
  421. else
  422. {
  423. while( !feof(iFileIdRead) )
  424. fputc(iFileIdWrite, fgetc(iFileIdRead));
  425.  
  426. fclose(iFileIdRead);
  427. fclose(iFileIdWrite);
  428. }
  429. }
  430. }
  431.  
  432. if( bFound )
  433. {
  434. new iBuffer[1024];
  435.  
  436. copy(iSpriteFile, 63, iSprite);
  437. formatex(iSprite, 63, "%s_%s", iCvarText, iIpAddress);
  438.  
  439. new iTextFile[128];
  440. formatex(iTextFile, 127, "sprites/wpn_%s_%s_%s.txt", iWpnName, iIpAddress, iCvarText);
  441. formatex(iBuffer, 1023, iWpnBuffer, IDENTICAL_320, IDENTICAL_640);
  442. format(iBuffer, 1023, iBuffer, iSprite, iSprite);
  443.  
  444. if( file_exists(iTextFile) )
  445. delete_file(iTextFile);
  446.  
  447. if( write_file(iTextFile, iBuffer) )
  448. {
  449. precache_generic(iSpriteFile);
  450. precache_generic(iTextFile);
  451. formatex(iToggleCmd, iLen, "wpn_%s_%s_%s", iWpnName, iIpAddress, iCvarText);
  452.  
  453. return 1;
  454. }
  455. }
  456. }
  457. else
  458. {
  459. new iTextFile[64], iBuffer[1024];
  460. formatex(iTextFile, 63, "sprites/weapon_%s_numb.txt", iWpnName);
  461. formatex(iBuffer, 1023, iWpnBuffer, IDENTICAL_320, IDENTICAL_640);
  462. format(iBuffer, 1023, iBuffer, iCvarText, iCvarText);
  463.  
  464. if( file_exists(iTextFile) )
  465. delete_file(iTextFile);
  466.  
  467. if( write_file(iTextFile, iBuffer) )
  468. {
  469. precache_generic(iSpriteFile);
  470. precache_generic(iTextFile);
  471. formatex(iToggleCmd, iLen, "weapon_%s_numb", iWpnName);
  472.  
  473. return 2;
  474. }
  475. }
  476. }
  477.  
  478. return 0;
  479. }
  480.  
  481. Menu_Open_Scope(iPlrId)
  482. {
  483. new iMenuBody[512], iMenuBodyLen, iKeys;
  484.  
  485. iMenuBodyLen = copy(iMenuBody, 511, "\rEgyeni sniper tavcsovek^n\yBy\w: \dNumb^n");
  486. if( g_iAWPFileName[0] )
  487. {
  488. iMenuBodyLen += copy(iMenuBody[iMenuBodyLen], (511-iMenuBodyLen), CheckPlayerBit(g_iCustomAwp, iPlrId)?"^n\r1\y. \wAWP\d: \yBE":"^n\r1\y. \wAWP\d: \yKI");
  489. iKeys |= MENU_KEY_1;
  490. }
  491. else
  492. iMenuBodyLen += copy(iMenuBody[iMenuBodyLen], (511-iMenuBodyLen), "^n\r1\y. \dAWP\w: \yHIBA");
  493. if( g_iScoutFileName[0] )
  494. {
  495. iMenuBodyLen += copy(iMenuBody[iMenuBodyLen], (511-iMenuBodyLen), CheckPlayerBit(g_iCustomScout, iPlrId)?"^n\r2\y. \wScout\d: \yBE":"^n\r2\y. \wScout\d: \yKI");
  496. iKeys |= MENU_KEY_2;
  497. }
  498. else
  499. iMenuBodyLen += copy(iMenuBody[iMenuBodyLen], (511-iMenuBodyLen), "^n\r2\y. \dScout\w: \yHIBA");
  500. if( g_iG3SG1FileName[0] )
  501. {
  502. iMenuBodyLen += copy(iMenuBody[iMenuBodyLen], (511-iMenuBodyLen), CheckPlayerBit(g_iCustomG3SG1, iPlrId)?"^n\r3\y. \wG3SG1\d: \yBE":"^n\r3\y. \wG3SG1\d: \yKI");
  503. iKeys |= MENU_KEY_3;
  504. }
  505. else
  506. iMenuBodyLen += copy(iMenuBody[iMenuBodyLen], (511-iMenuBodyLen), "^n\r3\y. \dG3SG1\w: \yHIBA");
  507. if( g_iSG550FileName[0] )
  508. {
  509. iMenuBodyLen += copy(iMenuBody[iMenuBodyLen], (511-iMenuBodyLen), CheckPlayerBit(g_iCustomSG550, iPlrId)?"^n\r4\y. \wSG550\d: \yBE":"^n\r4\y. \wSG550\d: \yKI");
  510. iKeys |= MENU_KEY_4;
  511. }
  512. else
  513. iMenuBodyLen += copy(iMenuBody[iMenuBodyLen], (511-iMenuBodyLen), "^n\r4\y. \dSG550\w: \yHIBA");
  514. iMenuBodyLen += formatex(iMenuBody[iMenuBodyLen], (511-iMenuBodyLen), "^n^n\r0\y. \wKilepes");
  515.  
  516. show_menu(iPlrId, (iKeys|MENU_KEY_0), iMenuBody, -1, "Custom Scopes");
  517. }
  518.  
  519. send_awp(iPlrId, bool:bReal=false, bool:bCheckActiveItem=true)
  520. {
  521. if( g_iAWPFileName[0] )
  522. {
  523. message_begin(MSG_ONE, g_iMsgId_WeaponList, _, iPlrId);
  524. write_string((bReal?"weapon_awp":g_iAWPFileName));
  525. write_byte(1);
  526. write_byte(30);
  527. write_byte(-1);
  528. write_byte(-1);
  529. write_byte(0);
  530. write_byte(2);
  531. write_byte(CSW_AWP);
  532. write_byte(0);
  533. message_end();
  534.  
  535. if( bReal )
  536. ClearPlayerBit(g_iCustomAwp, iPlrId);
  537. else
  538. SetPlayerBit(g_iCustomAwp, iPlrId);
  539.  
  540. if( bCheckActiveItem )
  541. check_active_item(iPlrId, CSW_AWP);
  542. }
  543. else
  544. ClearPlayerBit(g_iCustomAwp, iPlrId);
  545. }
  546.  
  547. send_scout(iPlrId, bool:bReal=false, bool:bCheckActiveItem=true)
  548. {
  549. if( g_iScoutFileName[0] )
  550. {
  551. message_begin(MSG_ONE, g_iMsgId_WeaponList, _, iPlrId);
  552. write_string((bReal?"weapon_scout":g_iScoutFileName));
  553. write_byte(2);
  554. write_byte(90);
  555. write_byte(-1);
  556. write_byte(-1);
  557. write_byte(0);
  558. write_byte(9);
  559. write_byte(CSW_SCOUT);
  560. write_byte(0);
  561. message_end();
  562.  
  563. if( bReal )
  564. ClearPlayerBit(g_iCustomScout, iPlrId);
  565. else
  566. SetPlayerBit(g_iCustomScout, iPlrId);
  567.  
  568. if( bCheckActiveItem )
  569. check_active_item(iPlrId, CSW_SCOUT);
  570. }
  571. else
  572. ClearPlayerBit(g_iCustomScout, iPlrId);
  573. }
  574.  
  575. send_g3sg1(iPlrId, bool:bReal=false, bool:bCheckActiveItem=true)
  576. {
  577. if( g_iG3SG1FileName[0] )
  578. {
  579. message_begin(MSG_ONE, g_iMsgId_WeaponList, _, iPlrId);
  580. write_string((bReal?"weapon_g3sg1":g_iG3SG1FileName));
  581. write_byte(2);
  582. write_byte(90);
  583. write_byte(-1);
  584. write_byte(-1);
  585. write_byte(0);
  586. write_byte(3);
  587. write_byte(CSW_G3SG1);
  588. write_byte(0);
  589. message_end();
  590.  
  591. if( bReal )
  592. ClearPlayerBit(g_iCustomG3SG1, iPlrId);
  593. else
  594. SetPlayerBit(g_iCustomG3SG1, iPlrId);
  595.  
  596. if( bCheckActiveItem )
  597. check_active_item(iPlrId, CSW_G3SG1);
  598. }
  599. else
  600. ClearPlayerBit(g_iCustomG3SG1, iPlrId);
  601. }
  602.  
  603. send_sg550(iPlrId, bool:bReal=false, bool:bCheckActiveItem=true)
  604. {
  605. if( g_iSG550FileName[0] )
  606. {
  607. message_begin(MSG_ONE, g_iMsgId_WeaponList, _, iPlrId);
  608. write_string((bReal?"weapon_sg550":g_iSG550FileName));
  609. write_byte(4);
  610. write_byte(90);
  611. write_byte(-1);
  612. write_byte(-1);
  613. write_byte(0);
  614. write_byte(16);
  615. write_byte(CSW_SG550);
  616. write_byte(0);
  617. message_end();
  618.  
  619. if( bReal )
  620. ClearPlayerBit(g_iCustomSG550, iPlrId);
  621. else
  622. SetPlayerBit(g_iCustomSG550, iPlrId);
  623.  
  624. if( bCheckActiveItem )
  625. check_active_item(iPlrId, CSW_SG550);
  626. }
  627. else
  628. ClearPlayerBit(g_iCustomSG550, iPlrId);
  629. }
  630.  
  631. check_active_item(iPlrId, iWpnType)
  632. {
  633. new iEnt = get_pdata_cbase(iPlrId, m_pActiveItem, 5);
  634. if( iEnt>0 )
  635. {
  636. if( get_pdata_int(iEnt, m_iId, 4)==iWpnType )
  637. {
  638. emessage_begin(MSG_ONE, g_iMsgId_CurWeapon, _, iPlrId);
  639. ewrite_byte(1);
  640. ewrite_byte(iWpnType);
  641. ewrite_byte(get_pdata_int(iEnt, m_iClip, 4));
  642. emessage_end(); // emessage_begin() and emessage_end() for "sniper crosshairs" plugin support.
  643. }
  644. }
  645. }
  646.  
  647. print_message(iPlrId) // using eng*, cause calling inside an event sometimes
  648. engclient_print(iPlrId, engprint_center, "^n^nIrd be ^"/tavcso^" a chatbe h valtoztasd a ^nSnipered Tavcsovet.");
  649.