HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4.  
  5. new const PLUGIN[] = "Admin Weapon Skins";
  6. new const VERSION[] = "1.0";
  7. new const AUTHOR[] = "mforce";
  8.  
  9.  
  10. #define ACCESS_FLAG ADMIN_KICK
  11.  
  12. const m_pPlayer = 41
  13. const m_iId = 43
  14. const XO_WEAPON = 4
  15. new Trie:weaponlist
  16.  
  17. #define get_weapon_owner(%1) get_pdata_cbase(%1, m_pPlayer, XO_WEAPON)
  18. #define get_weapon_id(%1) get_pdata_int(%1, m_iId, XO_WEAPON)
  19.  
  20. public plugin_init() {
  21. register_plugin(PLUGIN, VERSION, AUTHOR);
  22. }
  23.  
  24. public plugin_precache() {
  25. weaponlist = TrieCreate()
  26.  
  27. new sBuffer[256], sFile[64], sData[2][32], pFile;
  28.  
  29. get_localinfo("amxx_configsdir", sFile, charsmax(sFile));
  30. format(sFile, charsmax(sFile), "%s/admin_weapon_skins.ini", sFile);
  31.  
  32. pFile = fopen(sFile, "rt");
  33.  
  34. if(pFile) {
  35. while(!feof(pFile)) {
  36. fgets(pFile, sBuffer, charsmax(sBuffer));
  37. trim(sBuffer);
  38. if(sBuffer[0] == ';') continue;
  39.  
  40. parse(sBuffer, sData[0], charsmax(sData[]), sData[1], charsmax(sData[]));
  41.  
  42. if((containi(sData[0], "weapon_") != -1) && (containi(sData[1], ".mdl") != -1) && (!TrieKeyExists(weaponlist, sData[0]))) {
  43. precache_model(sData[1])
  44. RegisterHam(Ham_Item_Deploy, sData[0], "ItemDeploy_Post", true);
  45. TrieSetString(weaponlist, sData[0], sData[1])
  46. }
  47. }
  48. fclose(pFile);
  49. }
  50. else fprintf(pFile, ";^"weapon_ak47^" ^"models/adminskins/v_ak47.mdl^"^n");
  51. }
  52.  
  53. public ItemDeploy_Post(Ent) {
  54. if(Ent <=0)
  55. return HAM_IGNORED;
  56.  
  57. new id = get_weapon_owner(Ent)
  58. if((id > 0) && (get_user_flags(id) & ACCESS_FLAG)) {
  59. new szWeapon[32], WeaponPath[32];
  60. get_weaponname(get_weapon_id(Ent), szWeapon, charsmax(szWeapon));
  61.  
  62. TrieGetString(weaponlist, szWeapon, WeaponPath, charsmax(WeaponPath));
  63. set_pev(id, pev_viewmodel2, WeaponPath);
  64. }
  65. return HAM_IGNORED;
  66. }
  67.  
  68. public plugin_end() {
  69. TrieDestroy(weaponlist);
  70. }