Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
760
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmisc>
  2. #include <hamsandwich>
  3. #include <fakemeta>
  4. #include <cstrike>
  5.  
  6. #if AMXX_VERSION_NUM < 181
  7.     #assert AMX Mod X v1.8.1 or later library required!
  8. #endif
  9.  
  10. #if AMXX_VERSION_NUM <183
  11.     #define MAX_PLAYERS 32
  12. #endif
  13.  
  14. #pragma semicolon 1
  15.  
  16. enum _:ModelType
  17. {
  18.         vModel[45],
  19.         pModel[45]
  20. }
  21.  
  22. new const Models[][ModelType] =
  23. {
  24.         {       ""                                            , ""                                                      },
  25.         {       "models/csgo_knifes/bayonet/ct/v_knife.mdl"   , "models/csgo_knifes/bayonet/ct/p_knife.mdl"             },
  26.         {       "models/csgo_knifes/bayonet/t/v_knife.mdl"    , "models/csgo_knifes/bayonet/t/p_knife.mdl"              },
  27.         {       "models/csgo_knifes/butterfly/ct/v_knife.mdl" , "models/csgo_knifes/butterfly/ct/p_knife.mdl"           },
  28.         {       "models/csgo_knifes/butterfly/t/v_knife.mdl"  , "models/csgo_knifes/butterfly/t/p_knife.mdl"            },
  29.         {       "models/csgo_knifes/default/ct/v_knife.mdl"   , "models/csgo_knifes/default/ct/p_knife.mdl"             },
  30.         {       "models/csgo_knifes/default/t/v_knife.mdl"    , "models/csgo_knifes/default/t/p_knife.mdl"              },
  31.         {       "models/csgo_knifes/flip/ct/v_knife.mdl"      , "models/csgo_knifes/flip/ct/p_knife.mdl"                },
  32.         {       "models/csgo_knifes/flip/t/v_knife.mdl"       , "models/csgo_knifes/flip/t/p_knife.mdl"                 },
  33.         {       "models/csgo_knifes/gut/ct/v_knife.mdl"       , "models/csgo_knifes/gut/ct/p_knife.mdl"                 },
  34.         {       "models/csgo_knifes/gut/t/v_knife.mdl"        , "models/csgo_knifes/gut/t/p_knife.mdl"                  },
  35.         {       "models/csgo_knifes/huntsman/ct/v_knife.mdl"  , "models/csgo_knifes/huntsman/ct/p_knife.mdl"            },
  36.         {       "models/csgo_knifes/huntsman/t/v_knife.mdl"   , "models/csgo_knifes/huntsman/t/p_knife.mdl"             },
  37.         {       "models/csgo_knifes/karambit/ct/v_knife.mdl"  , "models/csgo_knifes/karambit/ct/p_knife.mdl"            },
  38.         {       "models/csgo_knifes/karambit/t/v_knife.mdl"   , "models/csgo_knifes/karambit/t/p_knife.mdl"             },
  39.         {       "models/csgo_knifes/m9_bayonet/ct/v_knife.mdl", "models/csgo_knifes/m9_bayonet/ct/p_knife.mdl"          },
  40.         {       "models/csgo_knifes/m9_bayonet/t/v_knife.mdl" , "models/csgo_knifes/m9_bayonet/t/p_knife.mdl"           }
  41. };
  42.  
  43. new const m_pPlayer = 41, XO_WEAPON = 4, Version[] = "1.1";
  44. new Array:HandleModelsArray;
  45. new KnifeId[MAX_PLAYERS];
  46.  
  47. public plugin_precache()
  48. {
  49.         new Size, Data[ModelType], bool:ResourcePrecached;
  50.         HandleModelsArray = ArrayCreate(ModelType);
  51.        
  52.     Size = sizeof Models;
  53.         for(new i = 0; i < Size; ++i)
  54.         {
  55.                ArrayPushArray(HandleModelsArray, Models[i]);
  56.         }
  57.        
  58.         Size = ArraySize(HandleModelsArray);
  59.         for(new i = 1; i < Size; ++i)
  60.         {
  61.                 ArrayGetArray(HandleModelsArray, i, Data);
  62.                 if(!file_exists(Data[vModel]) || !file_exists(Data[pModel]))
  63.                 {
  64.             log_amx("Fisierul %s si/sau fisierul %s lipsesc. Verifica daca ai introdus calea corect.", Data[vModel], Data[pModel]);
  65.             ArrayDeleteItem(HandleModelsArray, i--);
  66.             --Size;
  67.                         continue;
  68.                 }
  69.                
  70.         ResourcePrecached = true;
  71.                 precache_model(Data[vModel]);
  72.                 precache_model(Data[pModel]);
  73.         }
  74.     if ( !ResourcePrecached )
  75.     {
  76.         set_fail_state("Nu a fost detectat nici un model pentru cutite, pluginul se va auto-inchide.");
  77.     }
  78. }
  79.  
  80. public plugin_init()
  81. {
  82.         register_plugin("CSGO Knifes", Version, "lüxor");
  83.        
  84.         RegisterHam(Ham_Item_Deploy, "weapon_knife", "CBasePlayerItem_Deploy", 1);
  85.         RegisterHam(Ham_Spawn, "player", "CBasePlayer_Spawn", 1);
  86.        
  87.         register_cvar("csgo_knifes", Version, FCVAR_SERVER|FCVAR_SPONLY);
  88. }
  89.  
  90. public CBasePlayer_Spawn(id)
  91. {
  92.         if ( !is_user_alive(id) )
  93.         {
  94.                 return;
  95.         }
  96.  
  97.         new RandomNum = random_num(1, ArraySize(HandleModelsArray) -1);
  98.         KnifeId[id] = cs_get_user_team(id) == CS_TEAM_CT ? RandomNum * 2 - 1 : RandomNum * 2;
  99. }
  100.  
  101. public CBasePlayerItem_Deploy(ent)
  102. {
  103.         if(pev_valid(ent))
  104.         {
  105.                 new id = get_pdata_cbase(ent, m_pPlayer, XO_WEAPON), Data[ModelType];
  106.        
  107.                 ArrayGetArray(HandleModelsArray, KnifeId[id], Data);
  108.        
  109.                 set_pev(id, pev_viewmodel2, Data[vModel]);
  110.                 set_pev(id, pev_weaponmodel2, Data[pModel]);
  111.         }
  112. }
  113.  
  114. public plugin_end()
  115. {
  116.         ArrayDestroy(HandleModelsArray);
  117. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement