Advertisement
FlacoBey

Untitled

Jul 15th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.34 KB | None | 0 0
  1. #pragma newdecls required
  2. #pragma semicolon 1
  3.  
  4. #include <sourcemod>
  5. #include <sdktools>
  6.  
  7. #define MAXLIST 11
  8.  
  9. int iWeapon[2048 + 1], iAmmo[MAXPLAYERS + 1][2][2];
  10. bool iCookies[MAXPLAYERS + 1][2], iState[MAXPLAYERS + 1], IsMelee[MAXPLAYERS + 1][2], IsDual[MAXPLAYERS + 1][2];
  11. char sClassnameWeapon[MAXPLAYERS + 1][2][36];
  12.  
  13. static const char gModelsItemsList[MAXLIST][] =
  14. {
  15.     "models/weapons/melee/v_katana.mdl",                //0
  16.     "models/weapons/melee/v_fireaxe.mdl",               //1
  17.     "models/weapons/melee/v_machete.mdl",               //2
  18.     "models/weapons/melee/v_crowbar.mdl",               //3
  19.     "models/v_models/v_knife_t.mdl",                    //4
  20.     "models/weapons/melee/v_frying_pan.mdl",            //5
  21.     "models/weapons/melee/v_bat.mdl",                   //6
  22.     "models/weapons/melee/v_cricket_bat.mdl",           //7
  23.     "models/weapons/melee/v_tonfa.mdl",                 //8
  24.     "models/weapons/melee/v_electric_guitar.mdl",       //9
  25.     "models/weapons/melee/v_golfclub.mdl"               //10
  26. };
  27.  
  28. public void OnPluginStart()
  29. {
  30.     AddCommandListener(HookPlayerChat, "say");
  31.     RegConsoleCmd("s", cSwitch);
  32.     RegConsoleCmd("sm_s", cSwitch);
  33.     HookEvent("player_death", eDeath);
  34. }
  35.  
  36. public void eDeath(Event event, const char[] name, bool dontbroadcast)
  37. {
  38.     int client = GetClientOfUserId(event.GetInt("userid"));
  39.     if(client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2)
  40.     {
  41.         float vPos[3];
  42.         GetClientEyePosition(client, vPos);
  43.         for(int i; i < 2; i++)
  44.         {
  45.             int entity = CreateEntityByName(sClassnameWeapon[client][i]);
  46.             if(IsValidEntity(entity))
  47.             {
  48.                 TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
  49.                 DispatchSpawn(entity);
  50.             }
  51.             else
  52.             {
  53.                 entity = MeleeAwfull(sClassnameWeapon[client][i]);
  54.                 TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
  55.             }
  56.         }
  57.     }
  58.     for(int i; i < 2; i++)
  59.     {
  60.         Format(sClassnameWeapon[client][i], sizeof sClassnameWeapon[][], "null");
  61.     }
  62. }
  63.  
  64. public Action HookPlayerChat(int iClient, const char[] sCommand, int iArgs)
  65. {
  66.     if (StrEqual(sCommand, "say") || StrEqual(sCommand, "say_team"))
  67.     {
  68.         char sArg[2];
  69.         GetCmdArg(1, sArg, sizeof(sArg));
  70.         if(strcmp(sArg, "s") == 0)
  71.         {
  72.             cSwitch(iClient, 0);
  73.             return Plugin_Continue;
  74.         }
  75.     }
  76.     return Plugin_Continue;
  77. }  
  78.  
  79. public Action cSwitch (int client, int args)
  80. {
  81.     int iSlot = GetPlayerWeaponSlot(client, 1), AmmoType, Ammo, iClip;
  82.    
  83.     if(!iState[client])
  84.     {
  85.         if(!iCookies[client][0])
  86.         {
  87.             if(IsValidEntity(iSlot))
  88.             {
  89.                 GetEntityClassname(iSlot, sClassnameWeapon[client][0], sizeof sClassnameWeapon[][]);
  90.                 if(strcmp(sClassnameWeapon[client][0], "weapon_melee") == 0)
  91.                 {
  92.                     IsMelee[client][0] = true;
  93.                     char ModelName[128], sExplodeString[MAXLIST][56];
  94.                     int iNum;
  95.                     GetEntPropString(iSlot, Prop_Data, "m_ModelName", ModelName, sizeof ModelName);
  96.                     for(int i; i < MAXLIST; i++)
  97.                     {
  98.                         if(strcmp(ModelName, gModelsItemsList[i]) == 0)
  99.                         {
  100.                             iNum = ExplodeString(gModelsItemsList[i], "/", sExplodeString, sizeof sExplodeString, sizeof sExplodeString[]);
  101.                             ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "v_", "");
  102.                             if(StrContains(sExplodeString[iNum - 1], "knife") > 0)
  103.                                 ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "_t.mdl", "");
  104.                             else
  105.                                 ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], ".mdl", "");
  106.                             TrimString(sExplodeString[iNum - 1]);
  107.                             Format(sClassnameWeapon[client][0], sizeof sClassnameWeapon[][], "%s", sExplodeString[iNum - 1]);
  108.                             break;
  109.                         }
  110.                     }
  111.                 }
  112.                 else if(strcmp(sClassnameWeapon[client][0], "weapon_pistol") == 0 && GetEntProp(iSlot, Prop_Send, "m_hasDualWeapons"))
  113.                     IsDual[client][0] = true;
  114.  
  115.                 if(!IsMelee[client][0])
  116.                 {
  117.                     AmmoType = GetEntProp(iSlot, Prop_Send, "m_iPrimaryAmmoType");
  118.                     Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType);
  119.                     iClip = GetEntProp(iSlot, Prop_Send, "m_iClip1");
  120.                 }
  121.                
  122.                 iAmmo[client][0][0] = iClip;
  123.                 iAmmo[client][0][1] = Ammo;
  124.  
  125.                 RemovePlayerItem(client, iSlot);
  126.                 AcceptEntityInput(iSlot, "kill");
  127.                 iCookies[client][0] = true;
  128.                 if(iCookies[client][1])
  129.                 {
  130.                     iSlot = GetPlayerWeaponSlot(client, 1);
  131.                     if(!IsValidEntity(iSlot))
  132.                     {
  133.                         if(!IsMelee[client][1])
  134.                         {
  135.                             if(IsDual[client][1])
  136.                             {
  137.                                 int entity;
  138.                                 for(int i; i <= 2; i++)
  139.                                 {
  140.                                     entity = CreateEntityByName(sClassnameWeapon[client][1]);
  141.                                     DispatchSpawn(entity);
  142.                                     if(IsValidEntity(entity))
  143.                                     {
  144.                                         AcceptEntityInput(entity, "Use", client);
  145.                                     }
  146.                                 }
  147.                                
  148.                                 iWeapon[entity] = GetClientUserId(client);
  149.                                 CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
  150.                                 iCookies[client][1] = false;
  151.                                 IsDual[client][1] = false;
  152.                             }
  153.                             else
  154.                             {
  155.                                 int entity = CreateEntityByName(sClassnameWeapon[client][1]);
  156.                                 DispatchSpawn(entity);
  157.                                 if(IsValidEntity(entity))
  158.                                 {
  159.                                     AcceptEntityInput(entity, "Use", client);
  160.                                     iCookies[client][1] = false;
  161.                                 }
  162.                                 iWeapon[entity] = GetClientUserId(client);
  163.                                 CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
  164.                             }
  165.                         }
  166.                         else
  167.                         {
  168.                             int entity = MeleeAwfull(sClassnameWeapon[client][1]);
  169.                             AcceptEntityInput(entity, "Use", client);
  170.                             iCookies[client][1] = false;
  171.                             IsMelee[client][1] = false;
  172.                         }
  173.                     }
  174.                 }
  175.             }
  176.         }
  177.         else
  178.         {
  179.             iSlot = GetPlayerWeaponSlot(client, 1);
  180.             if(!IsValidEntity(iSlot))
  181.             {
  182.                 if(!IsMelee[client][0])
  183.                 {
  184.                     if(IsDual[client][0])
  185.                     {
  186.                         int entity;
  187.                         for(int i; i <= 2; i++)
  188.                         {
  189.                             entity = CreateEntityByName(sClassnameWeapon[client][0]);
  190.                             DispatchSpawn(entity);
  191.                             if(IsValidEntity(entity))
  192.                             {
  193.                                 AcceptEntityInput(entity, "Use", client);
  194.                             }
  195.                         }
  196.                        
  197.                         iWeapon[entity] = GetClientUserId(client);
  198.                         CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
  199.                         iCookies[client][0] = false;
  200.                         IsDual[client][0] = false;
  201.                     }
  202.                     else
  203.                     {
  204.                         int entity = CreateEntityByName(sClassnameWeapon[client][0]);
  205.                         DispatchSpawn(entity);
  206.                         if(IsValidEntity(entity))
  207.                         {
  208.                             AcceptEntityInput(entity, "Use", client);
  209.                             iCookies[client][0] = false;
  210.                         }
  211.                         iWeapon[entity] = GetClientUserId(client);
  212.                         CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
  213.                     }
  214.                 }
  215.                 else
  216.                 {
  217.                     int entity = MeleeAwfull(sClassnameWeapon[client][0]);
  218.                     AcceptEntityInput(entity, "Use", client);
  219.                     iCookies[client][0] = false;
  220.                     IsMelee[client][0] = false;
  221.                 }
  222.             }
  223.         }
  224.         iState[client] = true;
  225.     }
  226.     else
  227.     {
  228.         if(!iCookies[client][1])
  229.         {
  230.             if(IsValidEntity(iSlot))
  231.             {
  232.                 GetEntityClassname(iSlot, sClassnameWeapon[client][1], sizeof sClassnameWeapon[][]);
  233.                 if(strcmp(sClassnameWeapon[client][1], "weapon_melee") == 0)
  234.                 {
  235.                     IsMelee[client][1] = true;
  236.                     char ModelName[128], sExplodeString[MAXLIST - 6][36];
  237.                     int iNum;
  238.                     GetEntPropString(iSlot, Prop_Data, "m_ModelName", ModelName, sizeof ModelName);
  239.                     for(int i; i < MAXLIST; i++)
  240.                     {
  241.                         if(strcmp(ModelName, gModelsItemsList[i]) == 0)
  242.                         {
  243.                             iNum = ExplodeString(gModelsItemsList[i], "/", sExplodeString, sizeof sExplodeString, sizeof sExplodeString[]);
  244.                             ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "v_", "");
  245.                             if(StrContains(sExplodeString[iNum - 1], "knife") > 0)
  246.                                 ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "_t.mdl", "");
  247.                             else
  248.                                 ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], ".mdl", "");
  249.                             TrimString(sExplodeString[iNum - 1]);
  250.                             Format(sClassnameWeapon[client][1], sizeof sClassnameWeapon[][], "%s", sExplodeString[iNum - 1]);
  251.                             break;
  252.                         }
  253.                     }
  254.                 }
  255.                 else if(strcmp(sClassnameWeapon[client][1], "weapon_pistol") == 0 && GetEntProp(iSlot, Prop_Send, "m_hasDualWeapons"))
  256.                     IsDual[client][1] = true;
  257.  
  258.                 if(!IsMelee[client][1])
  259.                 {
  260.                     AmmoType = GetEntProp(iSlot, Prop_Send, "m_iPrimaryAmmoType");
  261.                     Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType);
  262.                     iClip = GetEntProp(iSlot, Prop_Send, "m_iClip1");
  263.                 }
  264.  
  265.                 iAmmo[client][1][0] = iClip;
  266.                 iAmmo[client][1][1] = Ammo;
  267.  
  268.                 RemovePlayerItem(client, iSlot);
  269.                 AcceptEntityInput(iSlot, "kill");
  270.                 iCookies[client][1] = true;
  271.                 if(iCookies[client][0])
  272.                 {
  273.                     iSlot = GetPlayerWeaponSlot(client, 1);
  274.                     if(!IsMelee[client][0])
  275.                     {
  276.                         if(IsDual[client][0])
  277.                         {
  278.                             int entity;
  279.                             for(int i; i <= 2; i++)
  280.                             {
  281.                                 entity = CreateEntityByName(sClassnameWeapon[client][0]);
  282.                                 DispatchSpawn(entity);
  283.                                 if(IsValidEntity(entity))
  284.                                 {
  285.                                     AcceptEntityInput(entity, "Use", client);
  286.                                 }
  287.                             }
  288.                             iWeapon[entity] = GetClientUserId(client);
  289.                             CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
  290.                             iCookies[client][0] = false;
  291.                             IsDual[client][0] = false;
  292.                         }
  293.                         else
  294.                         {
  295.                             int entity = CreateEntityByName(sClassnameWeapon[client][0]);
  296.                             DispatchSpawn(entity);
  297.                             if(IsValidEntity(entity))
  298.                             {
  299.                                 AcceptEntityInput(entity, "Use", client);
  300.                                 iCookies[client][0] = false;
  301.                             }
  302.                             iWeapon[entity] = GetClientUserId(client);
  303.                             CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
  304.                         }
  305.                     }
  306.                     else
  307.                     {
  308.                         int entity = MeleeAwfull(sClassnameWeapon[client][0]);
  309.                         AcceptEntityInput(entity, "Use", client);
  310.                         iCookies[client][0] = false;
  311.                         IsMelee[client][0] = false;
  312.                     }
  313.                 }
  314.             }
  315.         }
  316.         else
  317.         {
  318.             iSlot = GetPlayerWeaponSlot(client, 1);
  319.             if(!IsValidEntity(iSlot))
  320.             {
  321.                 if(!IsMelee[client][1])
  322.                 {
  323.                     if(IsDual[client][1])
  324.                     {
  325.                         int entity;
  326.                         for(int i; i <= 2; i++)
  327.                         {
  328.                             entity = CreateEntityByName(sClassnameWeapon[client][1]);
  329.                             DispatchSpawn(entity);
  330.                             if(IsValidEntity(entity))
  331.                             {
  332.                                 AcceptEntityInput(entity, "Use", client);
  333.                             }
  334.                         }
  335.                         iWeapon[entity] = GetClientUserId(client);
  336.                         CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
  337.                         iCookies[client][1] = false;
  338.                         IsDual[client][1] = false;
  339.                     }
  340.                     else
  341.                     {
  342.                         int entity = CreateEntityByName(sClassnameWeapon[client][1]);
  343.                         DispatchSpawn(entity);
  344.                         if(IsValidEntity(entity))
  345.                         {
  346.                             AcceptEntityInput(entity, "Use", client);
  347.                             iCookies[client][1] = false;
  348.                         }
  349.                         iWeapon[entity] = GetClientUserId(client);
  350.                         CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
  351.                     }
  352.                 }
  353.                 else
  354.                 {
  355.                     int entity = MeleeAwfull(sClassnameWeapon[client][1]);
  356.                     AcceptEntityInput(entity, "Use", client);
  357.                     iCookies[client][1] = false;
  358.                     IsMelee[client][1] = false;
  359.                 }
  360.             }
  361.         }
  362.         iState[client] = false;
  363.     }
  364.     return Plugin_Handled;
  365. }
  366.  
  367. public Action tXclip(Handle timer, int entity)
  368. {
  369.     entity = EntRefToEntIndex(entity);
  370.     if(entity != INVALID_ENT_REFERENCE)
  371.     {
  372.         int iAmmoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType");
  373.         if(iAmmoType)
  374.         {
  375.             int Clip, Ammo, client;
  376.             client = GetClientOfUserId(iWeapon[entity]);
  377.             Clip = iAmmo[client][0][0];
  378.             Ammo = iAmmo[client][0][1];
  379.            
  380.             int iCurrentWeapon = GetPlayerWeaponSlot(client, 1);
  381.             SetEntProp(client, Prop_Send, "m_iAmmo", Ammo, _, iAmmoType);
  382.             SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1",  Clip);
  383.         }
  384.     }
  385. }
  386.  
  387. public Action tXclip2(Handle timer, int entity)
  388. {
  389.     entity = EntRefToEntIndex(entity);
  390.     if(entity != INVALID_ENT_REFERENCE)
  391.     {
  392.         int iAmmoType = GetEntProp(entity, Prop_Send,  "m_iPrimaryAmmoType");
  393.         if(iAmmoType)
  394.         {
  395.             int Clip, Ammo, client;
  396.             client = GetClientOfUserId(iWeapon[entity]);
  397.             Clip = iAmmo[client][1][0];
  398.             Ammo = iAmmo[client][1][1];
  399.            
  400.             int iCurrentWeapon = GetPlayerWeaponSlot(client, 1);
  401.             SetEntProp(client, Prop_Send, "m_iAmmo", Ammo, _, iAmmoType);
  402.             SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1", Clip);
  403.         }
  404.     }
  405. }
  406.  
  407. int MeleeAwfull(const char[] Melee)
  408. {
  409.     int iMWeapon = CreateEntityByName("weapon_melee");
  410.  
  411.     if (IsValidEntity(iMWeapon))
  412.     {
  413.         DispatchKeyValue(iMWeapon, "melee_script_name", Melee);
  414.         DispatchSpawn(iMWeapon);
  415.        
  416.         char ModelName[128];
  417.         GetEntPropString(iMWeapon, Prop_Data, "m_ModelName", ModelName, sizeof ModelName);
  418.        
  419.         if (StrContains( ModelName, "hunter", false ) != -1)
  420.             AcceptEntityInput(iMWeapon, "kill");
  421.     }
  422.     return iMWeapon;
  423. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement