Advertisement
FlacoBey

Untitled

Jun 18th, 2019
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.76 KB | None | 0 0
  1. #pragma semicolon 1
  2.  #pragma newdecls required
  3.  
  4. #include <sourcemod>
  5. #include <sdktools>
  6.  
  7. #define MAXLIST 12
  8.  
  9. char Inflicted[MAXLIST][] =
  10. {  
  11.     "models/weapons/melee/v_fireaxe.mdl",
  12.     "models/weapons/melee/v_frying_pan.mdl",
  13.     "models/weapons/melee/v_machete.mdl",
  14.     "models/weapons/melee/v_bat.mdl",
  15.     "models/weapons/melee/v_crowbar.mdl",
  16.     "models/weapons/melee/v_cricket_bat.mdl",
  17.     "models/weapons/melee/v_tonfa.mdl",
  18.     "models/weapons/melee/v_katana.mdl",
  19.     "models/weapons/melee/v_electric_guitar.mdl",
  20.     "models/weapons/melee/v_golfclub.mdl",
  21.     "models/weapons/melee/v_riotshield.mdl",
  22.     "models/v_models/v_knife_t.mdl"
  23. };
  24.  
  25. int g_PlayerSecondaryWeapons[MAXPLAYERS + 1];
  26.  
  27. public void OnPluginStart()
  28. {
  29.     HookEvent("round_start", view_as<EventHook>(OnRoundStart), EventHookMode_PostNoCopy);
  30.     HookEvent("player_use", OnPlayerUse, EventHookMode_Post);
  31.     HookEvent("player_bot_replace", player_bot_replace);
  32.     HookEvent("bot_player_replace", bot_player_replace);
  33.     HookEvent("player_death", OnPlayerDeath, EventHookMode_Pre);
  34. }
  35.  
  36. public void OnMapStart()
  37. {
  38.     for (int i = 0; i <= MAXLIST; i++)
  39.     {
  40.         if(!IsModelPrecached(Inflicted[i])) PrecacheModel(Inflicted[i], true);;
  41.     }
  42. }
  43.  
  44. public void OnRoundStart()
  45. {
  46.     for (int i = 0; i <= MaxClients; i++)
  47.     {
  48.         g_PlayerSecondaryWeapons[i] = -1;
  49.     }
  50. }
  51.  
  52. public Action OnPlayerUse(Handle event, const char[] name, bool dontBroadcast)
  53. {
  54.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  55.    
  56.     if(client == 0 || !IsClientInGame(client))
  57.     {
  58.         return;
  59.     }
  60.    
  61.     int weapon = GetPlayerWeaponSlot(client, 1);
  62.    
  63.     g_PlayerSecondaryWeapons[client] = (weapon == -1 ? weapon : EntIndexToEntRef(weapon));
  64. }
  65.  
  66. public Action bot_player_replace(Handle event, const char[] name, bool dontBroadcast)
  67. {
  68.     int bot = GetClientOfUserId(GetEventInt(event, "bot"));
  69.     int client = GetClientOfUserId(GetEventInt(event, "player"));
  70.  
  71.     g_PlayerSecondaryWeapons[client] = g_PlayerSecondaryWeapons[bot];
  72.     g_PlayerSecondaryWeapons[bot] = -1;
  73. }
  74.  
  75. public Action player_bot_replace(Handle event, const char[] name, bool dontBroadcast)
  76. {
  77.     int client = GetClientOfUserId(GetEventInt(event, "player"));
  78.     int bot = GetClientOfUserId(GetEventInt(event, "bot"));
  79.  
  80.     g_PlayerSecondaryWeapons[bot] = g_PlayerSecondaryWeapons[client];
  81.     g_PlayerSecondaryWeapons[client] = -1;
  82. }
  83.  
  84. public Action OnPlayerDeath(Handle event, const char[] name, bool dontBroadcast)
  85. {
  86.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  87.    
  88.     if(client == 0 || !IsClientInGame(client))
  89.     {
  90.         return;
  91.     }
  92.    
  93.     int weapon = EntRefToEntIndex(g_PlayerSecondaryWeapons[client]);
  94.    
  95.     if(weapon == INVALID_ENT_REFERENCE)
  96.     {
  97.         return;
  98.     }
  99.  
  100.     if (weapon > 0)
  101.     {
  102.         char sWeapon[32];
  103.         int clip;
  104.         GetEdictClassname(weapon, sWeapon, 32);
  105.        
  106.         int index = CreateEntityByName(sWeapon);
  107.         float origin[3];
  108.         float ang[3];
  109.         if (StrEqual(sWeapon, "weapon_melee"))
  110.         {
  111.             char melee[156];
  112.             GetEntPropString(weapon , Prop_Data, "m_ModelName", melee, sizeof(melee));
  113.             for (int i = 0; i <= MAXLIST; i++)
  114.             {
  115.                 if(strcmp(melee, Inflicted[i]) == 0)
  116.                 {
  117.                    
  118.                     break;
  119.                 }
  120.             }
  121.         }
  122.         else if (StrEqual(sWeapon, "weapon_chainsaw"))
  123.         {
  124.             clip = GetEntProp(weapon, Prop_Send, "m_iClip1");
  125.         }
  126.         else if (StrEqual(sWeapon, "weapon_pistol") && (GetEntProp(weapon, Prop_Send, "m_isDualWielding") > 0))
  127.         {
  128.             int indexC = CreateEntityByName(sWeapon);
  129.             GetClientEyePosition(client,origin);
  130.             GetClientEyeAngles(client, ang);
  131.             GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
  132.             NormalizeVector(ang,ang);
  133.             ScaleVector(ang, 90.0);
  134.        
  135.             DispatchSpawn(indexC);
  136.             TeleportEntity(indexC, origin, NULL_VECTOR, ang);
  137.             ActivateEntity(indexC);
  138.         }
  139.         else if (StrEqual(sWeapon, "weapon_pistol_magnum"))
  140.         {
  141.             clip = GetEntProp(weapon, Prop_Send, "m_iClip1");
  142.         }
  143.  
  144.         RemovePlayerItem(client, weapon);
  145.        
  146.         GetClientEyePosition(client,origin);
  147.         GetClientEyeAngles(client, ang);
  148.         GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
  149.         NormalizeVector(ang,ang);
  150.         ScaleVector(ang, 90.0);
  151.        
  152.         DispatchSpawn(index);
  153.         TeleportEntity(index, origin, NULL_VECTOR, ang);
  154.         ActivateEntity(index);
  155.  
  156.         if (StrEqual(sWeapon, "weapon_chainsaw") || StrEqual(sWeapon, "weapon_pistol") || StrEqual(sWeapon, "weapon_pistol_magnum"))
  157.         {
  158.             SetEntProp(index, Prop_Send, "m_iClip1", clip);
  159.         }
  160.     }
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement