hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.05.23. 09:50



Jelenlévő felhasználók

Jelenleg 337 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 337 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: nincs regisztrált felhasználó az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 1 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Random fegyver
HozzászólásElküldve: 2014.04.10. 09:44 
Offline
Senior Tag
Avatar

Csatlakozott: 2014.01.20. 13:00
Hozzászólások: 216
Megköszönt másnak: 89 alkalommal
Megköszönték neki: 14 alkalommal
hali

Ebbe a pluginba valaki 4. es menübe (Menü neve mondjuk: Véletlenszerű fegyver) nem tudna csinálni egy olyat hogy Random fegyver (?)
És akkor ha rányom a játékos akkor kap egy véletlenszerüü fegyvert és mellé egy Deagle-t . :O
:geek:


SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6. #include <fun>
  7.  
  8. #define OFFSET_PRIMARYWEAPON 116
  9. #define OFFSET_C4_SLOT 372
  10. #define m_iMapZone 235
  11. #define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
  12. #define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0))
  13. #define JOG ADMIN_LEVEL_E
  14.  
  15. enum _:CHOICES
  16. {
  17. OPTION_NONE, OPTION_NEW, OPTION_OLD, OPTION_SAVE
  18. }
  19.  
  20. new const g_szOptions[CHOICES][] =
  21. {
  22. "Semmi", "\w[ \yUj fegyverek\w ]", "\w[ \yElozo fegyverekek\w ]", "\w[ \yElozo fegyverek \r+ \yMentes\w ]"
  23. }
  24.  
  25. new g_WeaponBPAmmo[] =
  26. {
  27. 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
  28. };
  29.  
  30. new g_WeaponSlots[] =
  31. {
  32. 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
  33. };
  34.  
  35. const m_iBuyingStatus = 34;
  36. new g_szWepFile[256], g_FilePointer;
  37. new g_pWeaponMenu, g_sWeaponMenu, g_SpawnMenu;
  38. new g_bSave[33], g_ipPreviousWeapons[33], g_isPreviousWeapons[33];
  39. new Array:g_PrimaryWeapons, Array:g_SecondaryWeapons;
  40. new g_MainMenuTitle, g_PrimaryMenuTitle, g_SecondaryMenuTitle, g_PluginPrefix, g_iToggle, g_iBlockDrop, g_iHENade, g_iFlash, g_iSmoke, g_vipiHENade, g_vipiFlash, g_vipiSmoke, g_iArmorAmount, g_iNVG, g_iUnlimitedAmmo, g_iStripMode, g_iTeamMode, g_iFastSwitch, g_iCZBotSupport;
  41. new g_szMainMenuTitle[32], g_szPriMenuTitle[32], g_szSecMenuTitle[32], g_szPrefixName[32];
  42. new bool:g_bomb_targ, g_iEnt, iconstatus;
  43. new CsTeams:g_MenuTeam, CsTeams:g_iPlayerTeam[33];
  44.  
  45. public plugin_init()
  46. {
  47. register_plugin("Weapon Menu", "0.0.9", "SavSin");
  48.  
  49. g_MainMenuTitle = register_cvar("wm_mainmenutitle", "|LCAW|"); //Main Menu Title Cvar.
  50. g_PrimaryMenuTitle = register_cvar("wm_primenutitle", "Fegyverek"); //Primary Weapons Menu Title Cvar.
  51. g_SecondaryMenuTitle = register_cvar("wm_secmenutitle", "Kispisztolyok"); //Secondary Weapons Menu Title Cvar.
  52. g_PluginPrefix = register_cvar("amx_prefix_name", "LCAW"); //Prefix Name Cvar.
  53.  
  54. g_iToggle = register_cvar("wm_switch", "1"); //Turns plugin on and off.
  55. g_iBlockDrop = register_cvar("wm_blockdrop", "0"); //Blocks weapon drop.
  56. g_iHENade = register_cvar("wm_henade", "1"); // Amount of HE Nades given to each player.
  57. g_iFlash = register_cvar("wm_flash", "2"); //Amount of Flash Nades given to each player.
  58. g_iSmoke = register_cvar("wm_smoke", "1"); //Amount of Smoke Nades given to each player.
  59. g_vipiHENade = register_cvar("wm_viphenade", "3"); // Amount of HE Nades given to each player.
  60. g_vipiFlash = register_cvar("wm_vipflash", "3"); //Amount of Flash Nades given to each player.
  61. g_vipiSmoke = register_cvar("wm_vipsmoke", "2"); //Amount of Smoke Nades given to each player.
  62. g_iArmorAmount = register_cvar("wm_armor", "100"); //Amount of Armor Given to each player.
  63. g_iNVG = register_cvar("wm_nvg", "1"); //Give NVG's?
  64. g_iUnlimitedAmmo = register_cvar("wm_unlimitedammo", "1"); //Allow Unlimited ammo?
  65. g_iStripMode = register_cvar("wm_stripmode", "1"); //1 = Strip and keep bomb 2 = Strip All.
  66. g_iFastSwitch = register_cvar("wm_fastswitch", "1"); //1 = Switch to last used weapon 0 = dont
  67.  
  68. g_iCZBotSupport = register_cvar("wm_czbotsupport", "0"); //1 = Rage method of CZ bot support 0 = no cz bot support.
  69.  
  70. register_concmd ("amx_teammode", "cmdTeamMode", ADMIN_BAN, "0 = No teams buy. 1 = CT buy. 2 = T buy.");
  71. register_concmd("wmadminmenu", "cmdAdminMenu", ADMIN_RCON, "Opens the admin menu.");
  72. register_concmd("say wmadmin", "cmdAdminMenu", ADMIN_RCON, "Opens the admin menu.");
  73.  
  74.  
  75. register_event("CurWeapon", "eCurWeapon", "be", "1=1"); //Unlimited ammo
  76.  
  77. get_pcvar_string(g_MainMenuTitle, g_szMainMenuTitle, charsmax(g_szMainMenuTitle)); //Main Menu Title Text
  78. get_pcvar_string(g_PrimaryMenuTitle, g_szPriMenuTitle, charsmax(g_szPriMenuTitle)); // Primary Menu Title Text
  79. get_pcvar_string(g_SecondaryMenuTitle, g_szSecMenuTitle, charsmax(g_szSecMenuTitle)); //Secondary Menu Title Text
  80. get_pcvar_string(g_PluginPrefix, g_szPrefixName, charsmax(g_szPrefixName)); //Prefix Name shows infront of plugin chat.
  81.  
  82. RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawn", 1); //Player Spawn Post
  83.  
  84. if(get_pcvar_num(g_iCZBotSupport))
  85. RegisterHam(Ham_Spawn, "czbot", "fwdPlayerSpawn", 1); //Player Spawn Post
  86.  
  87. RegisterHam(Ham_Touch, "func_buyzone", "fwdBuyZoneTouch", 1); //Player touches buyzone
  88. iconstatus = get_user_msgid("StatusIcon");
  89.  
  90. register_event("HLTV", "Event_HLTV_NewRound", "a", "1=0", "2=0"); //New round start
  91. register_event("TeamInfo", "eTeamInfo", "a"); //Event Team Info.
  92.  
  93. register_clcmd("say /guns", "cmdGuns"); //Re-Enables Gun menu
  94. register_clcmd("say guns", "cmdGuns"); //Re-Enables Gun menu
  95. register_clcmd("say_team /guns", "cmdGuns"); //Re-Enables Gun menu
  96. register_clcmd("say_team guns", "cmdGuns"); //Re-Enables Gun menu
  97.  
  98. register_clcmd("say /fegyo", "cmdGuns"); //Re-Enables Gun menu
  99. register_clcmd("say fegyo", "cmdGuns"); //Re-Enables Gun menu
  100. register_clcmd("say_team /fegyo", "cmdGuns"); //Re-Enables Gun menu
  101. register_clcmd("say_team fegyo", "cmdGuns"); //Re-Enables Gun menu
  102.  
  103. register_clcmd("drop", "blockDrop"); //Re-Enables Gun menu
  104.  
  105. CreateWeaponsArray(); //Create the menus and arrays
  106.  
  107. new szNum[3];
  108. g_SpawnMenu = menu_create(g_szMainMenuTitle, "HandleSpawnMenu"); //Create Main Menu
  109.  
  110. for(new i = 1; i < sizeof(g_szOptions); i++) //Loop through all the options
  111. {
  112. num_to_str(i, szNum, charsmax(szNum));
  113. menu_additem(g_SpawnMenu, g_szOptions[i], szNum, 0); //Add the options to the menu
  114. }
  115.  
  116. menu_setprop(g_SpawnMenu , MPROP_EXIT , MEXIT_NEVER); //Dont allow Menu to exit
  117.  
  118. if (fm_find_ent_by_class(-1, "func_bomb_target") || fm_find_ent_by_class(-1, "info_bomb_target")) //Checks for bombsites
  119. {
  120. g_bomb_targ = true; //If there is a bomb site Set this to true
  121. }
  122. }
  123.  
  124. public client_disconnect(id)
  125. {
  126. g_ipPreviousWeapons[id] = 0;
  127. g_isPreviousWeapons[id] = 0;
  128. g_bSave[id] = false;
  129. }
  130.  
  131. public client_connect(id)
  132. {
  133. g_ipPreviousWeapons[id] = 0;
  134. g_isPreviousWeapons[id] = 0;
  135. g_bSave[id] = false;
  136. }
  137.  
  138. public plugin_precache()
  139. {
  140. g_iTeamMode = register_cvar("wm_teammode", "0"); // 0 = both 1 = T only 2 = CT only.
  141. g_iEnt = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_map_parameters"));
  142. dllfunc(DLLFunc_Spawn, g_iEnt);
  143. server_cmd("sv_restart 1");
  144. }
  145.  
  146. public Event_HLTV_NewRound()
  147. {
  148.  
  149. if(!get_pcvar_num(g_iToggle))
  150. return PLUGIN_HANDLED;
  151.  
  152. new iTeamMode;
  153.  
  154. switch(clamp(get_pcvar_num(g_iTeamMode), 0, 2))
  155. {
  156. case 0:
  157. {
  158. iTeamMode = 3;
  159. }
  160. case 1:
  161. {
  162. g_MenuTeam = CS_TEAM_T;
  163. iTeamMode = 1;
  164. }
  165. case 2:
  166. {
  167. g_MenuTeam = CS_TEAM_CT;
  168. iTeamMode = 2;
  169. }
  170. }
  171.  
  172. set_pdata_int(g_iEnt, m_iBuyingStatus, iTeamMode, 4);
  173. return PLUGIN_HANDLED;
  174. }
  175.  
  176. public fwdBuyZoneTouch(iEnt, id)
  177. {
  178. if(!get_pcvar_num(g_iToggle))
  179. return HAM_IGNORED;
  180. if(is_user_connected(id) && g_iPlayerTeam[id] == g_MenuTeam)
  181. {
  182. message_begin(MSG_ONE, iconstatus, {0,0,0}, id);
  183. write_byte(0);
  184. write_string("buyzone");
  185. write_byte(0);
  186. write_byte(255);
  187. write_byte(0);
  188. message_end();
  189. }
  190. return PLUGIN_HANDLED;
  191. }
  192.  
  193. public cmdTeamMode(id)
  194. {
  195. if(!get_pcvar_num(g_iToggle))
  196. return PLUGIN_HANDLED;
  197. new arg[2];
  198. read_argv(1, arg, sizeof(arg));
  199.  
  200. new iArg = str_to_num(arg);
  201.  
  202. set_pcvar_num(g_iTeamMode, clamp(iArg, 0, 2));
  203. server_cmd("sv_restart 1");
  204.  
  205. return PLUGIN_HANDLED;
  206. }
  207.  
  208. public cmdGuns(id) //Renable Guns Menu
  209. {
  210. if(get_pcvar_num(g_iToggle) && g_bSave[id])
  211. {
  212. g_bSave[id] = false;
  213. client_print(id, print_chat, "[%s] A fegyvermenu a kov. korben mar elerheto szamodra.", g_szPrefixName);
  214. }
  215. }
  216.  
  217. public fwdPlayerSpawn(id)
  218. {
  219. if(is_user_alive(id) && get_pcvar_num(g_iToggle)) //Check if player alive and plugin is active
  220. {
  221. if(get_pcvar_num(g_iTeamMode))
  222. {
  223. if(g_iPlayerTeam[id] == g_MenuTeam)
  224. {
  225. switch(get_pcvar_num(g_iStripMode))
  226. {
  227. case 1: //Strip and keep bomb
  228. {
  229. StripUserWeapons(id); //Calls the Strip Function
  230. }
  231. case 2: // Strip Everything
  232. {
  233. strip_user_weapons(id); //Fun native to strip ALL weapons
  234. give_item(id, "weapon_knife"); //Fun native to give the knife back
  235. }
  236. }
  237. }
  238. }
  239. else
  240. {
  241. switch(get_pcvar_num(g_iStripMode))
  242. {
  243. case 1: //Strip and keep bomb
  244. {
  245. StripUserWeapons(id); //Calls the Strip Function
  246. }
  247. case 2: // Strip Everything
  248. {
  249. strip_user_weapons(id); //Fun native to strip ALL weapons
  250. give_item(id, "weapon_knife"); //Fun native to give the knife back
  251. }
  252. }
  253. }
  254.  
  255. if(g_bomb_targ && get_pcvar_num(g_iStripMode) == 1 && g_iPlayerTeam[id] == CS_TEAM_CT)
  256. {
  257. cs_set_user_defuse(id, 1); //If there is a bomb site and your a CT give you a Defuse kit
  258. }
  259.  
  260. if(get_pcvar_num(g_iHENade)) //Check if Grenades are enabled
  261. {
  262. //g_HeNadesLeft[id] = get_pcvar_num(g_iHENade);
  263. //Gives player the right amount of grenades
  264. give_item(id, "weapon_hegrenade");
  265. cs_set_user_bpammo(id, CSW_HEGRENADE, get_pcvar_num(g_iHENade));
  266. }
  267. if(get_user_flags(id) & JOG) {
  268. if(get_pcvar_num(g_vipiHENade)) //Check if Grenades are enabled
  269. {
  270. //g_HeNadesLeft[id] = get_pcvar_num(g_iHENade);
  271. //Gives player the right amount of grenades
  272. give_item(id, "weapon_hegrenade");
  273. cs_set_user_bpammo(id, CSW_HEGRENADE, get_pcvar_num(g_vipiHENade));
  274. }
  275. }
  276. if(get_pcvar_num(g_iFlash)) //Checks if Flashbangs are enabled
  277. {
  278. //Gives player the correct amount of flashbangs
  279. give_item(id, "weapon_flashbang");
  280. cs_set_user_bpammo(id, CSW_FLASHBANG, get_pcvar_num(g_iFlash));
  281. }
  282. if(get_user_flags(id) & JOG) {
  283. if(get_pcvar_num(g_vipiFlash)) //Checks if Flashbangs are enabled
  284. {
  285. //Gives player the correct amount of flashbangs
  286. give_item(id, "weapon_flashbang");
  287. cs_set_user_bpammo(id, CSW_FLASHBANG, get_pcvar_num(g_vipiFlash));
  288. }
  289. }
  290. if(get_pcvar_num(g_iSmoke)) //Checks if smoke is enabled
  291. {
  292. //Gives Player the correct amount of Smoke Grenades
  293. give_item(id, "weapon_smokegrenade");
  294. cs_set_user_bpammo(id, CSW_SMOKEGRENADE, get_pcvar_num(g_iSmoke));
  295. }
  296. if(get_user_flags(id) & JOG) {
  297. if(get_pcvar_num(g_vipiSmoke)) //Checks if smoke is enabled
  298. {
  299. //Gives Player the correct amount of Smoke Grenades
  300. give_item(id, "weapon_smokegrenade");
  301. cs_set_user_bpammo(id, CSW_SMOKEGRENADE, get_pcvar_num(g_vipiSmoke));
  302. }
  303. }
  304. //Gives the player the amount of armor based on the cvar above.
  305. cs_set_user_armor(id, get_pcvar_num(g_iArmorAmount), CS_ARMOR_VESTHELM);
  306.  
  307. if(get_pcvar_num(g_iNVG)) //Night Vision enabled?
  308. {
  309. cs_set_user_nvg(id, 1); //Gives the user night vision
  310. }
  311.  
  312. if(get_pcvar_num(g_iTeamMode))
  313. {
  314. if(g_iPlayerTeam[id] == g_MenuTeam)
  315. {
  316. if(!is_user_bot(id))
  317. {
  318. if(!g_bSave[id]) //Checks weather you have saved your previous weapons or not.
  319. {
  320. menu_display(id, g_SpawnMenu); //Shows the menu if you havn't saved your previous
  321. }
  322. else
  323. {
  324. PreviousWeapons(id); //Gives you the weapons you saved in from the menu
  325. }
  326. }
  327. else
  328. {
  329. new iPrimaryArraySize = ArraySize(g_PrimaryWeapons);
  330. new iSecondaryArraySize = ArraySize(g_SecondaryWeapons);
  331. for(new i=0; i< 2; i++)
  332. {
  333. new WeaponName[32], szArrayData[32];
  334. if(i == 0)
  335. {
  336. ArrayGetString(g_PrimaryWeapons, iPrimaryArraySize, szArrayData, charsmax(szArrayData)); //Gets the weapon name from the array
  337. }
  338. else
  339. {
  340. ArrayGetString(g_SecondaryWeapons, iSecondaryArraySize, szArrayData, charsmax(szArrayData)); //Gets the weapon name from the array
  341. }
  342.  
  343. replace_all(szArrayData, charsmax(szArrayData), " ", ""); //removes the spaces
  344. format(WeaponName, charsmax(WeaponName), "weapon_%s", szArrayData); //adds weapon_ to the weapon name
  345. strtolower(WeaponName);//Converts all to lower case
  346. GiveWeapons(id, WeaponName); //Gives secondary weapon
  347. }
  348. }
  349. }
  350. }
  351. else
  352. {
  353. if(!is_user_bot(id))
  354. {
  355. if(!g_bSave[id]) //Checks weather you have saved your previous weapons or not.
  356. {
  357. menu_display(id, g_SpawnMenu); //Shows the menu if you havn't saved your previous
  358. }
  359. else
  360. {
  361. PreviousWeapons(id); //Gives you the weapons you saved in from the menu
  362. }
  363. }
  364. else
  365. {
  366. new iPrimaryWeapon = random_num(0, ArraySize(g_PrimaryWeapons)-1);
  367. new iSecondaryWeapon = random_num(0, ArraySize(g_SecondaryWeapons)-1);
  368. for(new i=0; i< 2; i++)
  369. {
  370. new WeaponName[32], szArrayData[32];
  371. if(i == 0)
  372. {
  373. ArrayGetString(g_PrimaryWeapons, iPrimaryWeapon, szArrayData, charsmax(szArrayData)); //Gets the weapon name from the array
  374. }
  375. else
  376. {
  377. ArrayGetString(g_SecondaryWeapons, iSecondaryWeapon, szArrayData, charsmax(szArrayData)); //Gets the weapon name from the array
  378. }
  379.  
  380. replace_all(szArrayData, charsmax(szArrayData), " ", ""); //removes the spaces
  381. format(WeaponName, charsmax(WeaponName), "weapon_%s", szArrayData); //adds weapon_ to the weapon name
  382. strtolower(WeaponName);//Converts all to lower case
  383. GiveWeapons(id, WeaponName); //Gives secondary weapon
  384. }
  385. }
  386. }
  387. }
  388. }
  389.  
  390. public eCurWeapon(id)
  391. {
  392. if(!get_pcvar_num(g_iToggle) || !get_pcvar_num(g_iUnlimitedAmmo))
  393. return PLUGIN_HANDLED;
  394.  
  395. new iWeapon = read_data(2); //Gets current Weapon ID CSW weapon constraints
  396.  
  397. if(g_WeaponSlots[iWeapon] == 1 || g_WeaponSlots[iWeapon] == 2)
  398. {
  399. if(cs_get_user_bpammo(id, iWeapon) < g_WeaponBPAmmo[iWeapon])
  400. {
  401. cs_set_user_bpammo(id, iWeapon, g_WeaponBPAmmo[iWeapon]); //If your bp ammo is lower then the max then set it to the max
  402. }
  403. }
  404. return PLUGIN_CONTINUE;
  405. }
  406.  
  407. public blockDrop(id) //Blocks weapon drop
  408. {
  409. if(get_pcvar_num(g_iToggle) && get_pcvar_num(g_iBlockDrop) && get_user_weapon(id) != CSW_C4)
  410. {
  411. if(get_pcvar_num(g_iTeamMode))
  412. {
  413. if(g_iPlayerTeam[id] == g_MenuTeam)
  414. {
  415. client_print(id, print_center, "Nem dobhatod el a fegyvereidet.");
  416. return PLUGIN_HANDLED;
  417. }
  418. }
  419. else
  420. {
  421. client_print(id, print_center, "Nem dobhatod el a fegyvereidet.");
  422. return PLUGIN_HANDLED;
  423. }
  424. }
  425. return PLUGIN_CONTINUE;
  426. }
  427.  
  428. public HandleSpawnMenu(id, iMenu, iItem)
  429. {
  430. new szKey[3], Dummy;
  431. menu_item_getinfo(iMenu, iItem, Dummy, szKey, 2, "", 0, Dummy); //Gets the selection off the menu
  432.  
  433. switch(str_to_num(szKey))
  434. {
  435. case OPTION_NEW:
  436. {
  437. menu_display(id, g_pWeaponMenu); //Displays primary weapons menu
  438. }
  439. case OPTION_OLD:
  440. {
  441. PreviousWeapons(id); //Gives your previous weapons
  442. }
  443. case OPTION_SAVE:
  444. {
  445. PreviousWeapons(id); //Same as OPTION_OLD but saves it so you get these weapons each spawn.
  446. g_bSave[id] = true;
  447. client_print(id, print_chat, "[%s] Ird be /guns hogy engedelyezd a fegyvermenu-t.", g_szPrefixName);
  448. }
  449. }
  450. return PLUGIN_CONTINUE;
  451. }
  452.  
  453. public PreviousWeapons(id) //Access the array to give you the previous weapons used by you.
  454. {
  455. new szpData[32], szsData[32];
  456. ArrayGetString(g_PrimaryWeapons, g_ipPreviousWeapons[id], szpData, charsmax(szpData)); //Gets the array item of your previous primary weapon
  457. ArrayGetString(g_SecondaryWeapons, g_isPreviousWeapons[id], szsData, charsmax(szsData)); //Gets the array item of your previous secondary weapon
  458. strtolower(szpData); //Converts it all to lower case
  459. strtolower(szsData); //Converts it all to lower case
  460. replace_all(szpData, charsmax(szpData), " ", ""); //Removes spaces from the array text.
  461. replace_all(szsData, charsmax(szsData), " ", ""); //Removes spaces from the array text.
  462. format(szpData, charsmax(szpData), "weapon_%s", szpData); //adds weapon_ infront of the array text.
  463. format(szsData, charsmax(szsData), "weapon_%s", szsData);//adds weapon_ infront of the array text.
  464. GiveWeapons(id, szpData); //Gives player previous primary weapon
  465. GiveWeapons(id, szsData); //Gives player previous Secondary Weapon
  466. }
  467.  
  468. public CreateWeaponsArray()
  469. {
  470. get_configsdir(g_szWepFile, charsmax(g_szWepFile)); //gets addons/amxmodx/configs directory
  471. format(g_szWepFile, charsmax(g_szWepFile), "%s/DM_WeaponOrder.ini", g_szWepFile); //formats the file name for the Weapons order INI
  472. g_FilePointer = fopen(g_szWepFile, "r"); //Opens the file
  473. //Arrays
  474. g_PrimaryWeapons = ArrayCreate(15); //Creates the Primary Weapons Array
  475. g_SecondaryWeapons = ArrayCreate(15); //Creates the Secondary Weapons Array
  476.  
  477. //Weapon Menus
  478. g_pWeaponMenu = menu_create(g_szPriMenuTitle, "HandlePrimaryWeapons"); //Creates the Primary Weapon Menu
  479. g_sWeaponMenu = menu_create(g_szSecMenuTitle, "HandleSecondaryWeapons"); //Creates the Secondary Weapon Menu
  480.  
  481. new szData[32], szWeaponName[32], szpNum[3], szsNum[3];
  482. new pCounter, sCounter;
  483. if(g_FilePointer) //Makes sure the files open
  484. {
  485. while(!feof(g_FilePointer))
  486. {
  487. fgets(g_FilePointer, szData, charsmax(szData)); //Reads a line of the file
  488. trim(szData); //Removes '^n' new line character from the end of the line
  489. if(containi(szData, ";") != -1) //Checks to see if its a comment and then ignores it
  490. continue;
  491. //Check Weapon Slot for Menu Placement
  492. copy(szWeaponName, charsmax(szWeaponName), szData); //Copys the file data into a new variable to alter it
  493. replace_all(szWeaponName, charsmax(szWeaponName), " ", ""); //Removes Spaces from the Text
  494. format(szWeaponName, charsmax(szWeaponName), "weapon_%s", szWeaponName); //Adds Weapon_ to the text
  495. strtolower(szWeaponName); //converts the whole thing to lower case
  496. new iWeaponID = get_weaponid(szWeaponName); //Gets the CSW weapon constraint for that weapon
  497.  
  498. switch(g_WeaponSlots[iWeaponID]) //Checks which slot the weapon is for
  499. {
  500. case 1: //Primary Slot
  501. {
  502. ArrayPushString(g_PrimaryWeapons, szData); //Adds the original text to the array
  503. num_to_str(pCounter, szpNum, charsmax(szpNum));
  504. menu_additem(g_pWeaponMenu, szData, szpNum, 0); //Adds item to the primary weapons menu
  505. ++pCounter;
  506. }
  507. case 2: //Secondary Slot
  508. {
  509. ArrayPushString(g_SecondaryWeapons, szData); //Adds the original text to the array
  510. num_to_str(sCounter, szsNum, charsmax(szsNum));
  511. menu_additem(g_sWeaponMenu, szData, szsNum, 0);//Adds item to the Secondary Weapons Menu
  512. ++sCounter;
  513. }
  514. }
  515. }
  516. }
  517. else
  518. {
  519. set_fail_state("Failed to Open Weapons List");
  520. }
  521. //Blocks exit for both primary and secondary menus
  522. menu_setprop(g_pWeaponMenu , MPROP_EXIT , MEXIT_NEVER);
  523. menu_setprop(g_sWeaponMenu , MPROP_EXIT , MEXIT_NEVER);
  524.  
  525. fclose(g_FilePointer); //Closes the file
  526. }
  527.  
  528. public HandlePrimaryWeapons(id, iMenu, iItem)
  529. {
  530. new szKey[3], iSelectedWeapon, Dummy;
  531. menu_item_getinfo(iMenu, iItem, Dummy, szKey, 2, "", 0, Dummy); //Gets the primary weapon selected.
  532.  
  533. iSelectedWeapon = str_to_num(szKey);
  534. g_ipPreviousWeapons[id] = iSelectedWeapon; //Stores the selected weapon for option 2 and 3 on the main menu
  535.  
  536. new WeaponName[32], szArrayData[32];
  537. ArrayGetString(g_PrimaryWeapons, iSelectedWeapon, szArrayData, charsmax(szArrayData)); //Gets the weapon name from the array
  538. replace_all(szArrayData, charsmax(szArrayData), " ", ""); //removes the spaces
  539. format(WeaponName, charsmax(WeaponName), "weapon_%s", szArrayData); //adds weapon_ to the weapon name
  540. strtolower(WeaponName);//Converts all to lower case
  541. GiveWeapons(id, WeaponName); //Gives primary weapon
  542.  
  543. menu_display(id, g_sWeaponMenu); //Displays secondary weapons menu
  544. }
  545.  
  546. public HandleSecondaryWeapons(id, iMenu, iItem)
  547. {
  548. new szKey[3], iSelectedWeapon, Dummy;
  549. menu_item_getinfo(iMenu, iItem, Dummy, szKey, 2, "", 0, Dummy); //Gets the secondary weapon selected
  550.  
  551. iSelectedWeapon = str_to_num(szKey);
  552. g_isPreviousWeapons[id] = iSelectedWeapon; //Stores the selected weapon for option 2 and 3 on the main menu
  553.  
  554. new WeaponName[32], szArrayData[32];
  555. ArrayGetString(g_SecondaryWeapons, iSelectedWeapon, szArrayData, charsmax(szArrayData)); //Gets the weapon name from the array
  556. replace_all(szArrayData, charsmax(szArrayData), " ", ""); //removes the spaces
  557. format(WeaponName, charsmax(WeaponName), "weapon_%s", szArrayData); //adds weapon_ to the weapon name
  558. strtolower(WeaponName);//Converts all to lower case
  559. GiveWeapons(id, WeaponName); //Gives secondary weapon
  560. }
  561.  
  562. public grenade_throw(id , greindex , wId) //When a grenade is thrown switch to last inv automatically
  563. {
  564. if(get_pcvar_num(g_iToggle) && get_pcvar_num(g_iFastSwitch))
  565. {
  566. client_cmd(id, "lastinv");
  567. }
  568. }
  569.  
  570. stock GiveWeapons(id, szWeapon[])
  571. {
  572. if(is_user_connected(id))
  573. {
  574. new iWeaponId = get_weaponid(szWeapon); //Get the weapon id of the weapon given
  575. give_item(id, szWeapon); //Give the weapon
  576. cs_set_user_bpammo(id, iWeaponId, g_WeaponBPAmmo[iWeaponId]); //Set the ammo to max ammo
  577. }
  578. }
  579.  
  580. stock StripUserWeapons(id)
  581. {
  582. new iC4Ent = get_pdata_cbase(id, OFFSET_C4_SLOT); //Gets the slot for C4
  583.  
  584. if( iC4Ent > 0 ) //If you have the C4
  585. {
  586. set_pdata_cbase(id, OFFSET_C4_SLOT, FM_NULLENT); //Remove it
  587. }
  588.  
  589. strip_user_weapons(id); //Strip User weapons
  590. give_item(id, "weapon_knife"); //Give the knife
  591. set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0); //Set primary weapon offset to 0
  592.  
  593. if( iC4Ent > 0 ) //if you had the c4
  594. {
  595. set_pev(id, pev_weapons, pev(id, pev_weapons) | (1<<CSW_C4)); //Give it back
  596. set_pdata_cbase(id, OFFSET_C4_SLOT, iC4Ent); //Set the offset back to normal
  597. cs_set_user_bpammo(id, CSW_C4, 1); //Give the backpack
  598. cs_set_user_plant(id, 1); //Allow user to plant it
  599. }
  600. return PLUGIN_HANDLED;
  601. }
  602.  
  603. public eTeamInfo()
  604. {
  605. if(!get_pcvar_num(g_iToggle))
  606. return PLUGIN_HANDLED;
  607.  
  608. new id = read_data(1);
  609. new szTeam[2];
  610. read_data(2, szTeam, charsmax(szTeam));
  611. switch(szTeam[0])
  612. {
  613. case 'T':
  614. {
  615. g_iPlayerTeam[id] = CS_TEAM_T;
  616. }
  617. case 'C':
  618. {
  619. g_iPlayerTeam[id] = CS_TEAM_CT;
  620. }
  621. }
  622.  
  623. return PLUGIN_HANDLED;
  624. }
  625.  
  626. public cmdAdminMenu(id)
  627. {
  628. if(!get_pcvar_num(g_iToggle))
  629. return PLUGIN_HANDLED;
  630.  
  631. new iAdminMenu = menu_create("WM Admin MenĂĽ", "HandleAdminMenu");
  632.  
  633. switch(get_pcvar_num(g_iTeamMode))
  634. {
  635. case 1:
  636. {
  637. menu_additem(iAdminMenu, "\rCsak Terroristák", "0", 0);
  638. }
  639. case 2:
  640. {
  641. menu_additem(iAdminMenu, "\rCsak CT-k", "0", 0);
  642. }
  643. default:
  644. {
  645. menu_additem(iAdminMenu, "\rMindkét csapat", "0", 0);
  646. }
  647. }
  648.  
  649. menu_additem(iAdminMenu, "Mentés és kilépés", "1", 0);
  650.  
  651. menu_setprop(iAdminMenu , MPROP_EXIT , MEXIT_NEVER); //Dont allow Menu to exit
  652.  
  653. menu_display(id, iAdminMenu);
  654.  
  655. return PLUGIN_HANDLED;
  656. }
  657.  
  658. public ChangeTeamMode(id, CsTeams:iTeam, iValue)
  659. {
  660. set_pcvar_num(g_iTeamMode, iValue);
  661. g_MenuTeam = iTeam;
  662. switch(iTeam)
  663. {
  664. case CS_TEAM_T: client_print(id, print_center, "Csak Terroristák használhatják a menüt!");
  665. case CS_TEAM_CT: client_print(id, print_center, "Csak CT-k használhatják a menüt!");
  666. default: client_print(id, print_center, "Mindkét csapat használhatja a menüt!");
  667. }
  668. }
  669.  
  670. public HandleAdminMenu(id, iMenu, iItem)
  671. {
  672. new szKey[3], bool:bUpdateMenu, Dummy;
  673. menu_item_getinfo(iMenu, iItem, Dummy, szKey, 2, "", 0, Dummy); //Gets the primary weapon selected.
  674.  
  675. switch(str_to_num(szKey))
  676. {
  677. case 0:
  678. {
  679. switch(get_pcvar_num(g_iTeamMode))
  680. {
  681. case 1:
  682. {
  683. ChangeTeamMode(id, CS_TEAM_CT, 2);
  684. bUpdateMenu = true;
  685. }
  686. case 2:
  687. {
  688. ChangeTeamMode(id, CS_TEAM_UNASSIGNED, 0);
  689. bUpdateMenu = true;
  690. }
  691. default:
  692. {
  693. ChangeTeamMode(id, CS_TEAM_T, 1);
  694. bUpdateMenu = true;
  695. }
  696. }
  697. }
  698. case 1:
  699. {
  700. server_cmd("sv_restart 1");
  701. }
  702. }
  703.  
  704. if(bUpdateMenu)
  705. {
  706. menu_destroy(iMenu);
  707. cmdAdminMenu(id);
  708. }
  709. else
  710. {
  711. menu_destroy(iMenu);
  712. }
  713. }
  714.  

_________________
Kép
Kép
https://soundcloud.com/l-c-a-w


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 1 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 21 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole