Advertisement
FlacoBey

Untitled

Jun 20th, 2019
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.00 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", 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 - 1; i++)
  39.     {
  40.         if(!IsModelPrecached(Inflicted[i])) PrecacheModel(Inflicted[i], true);
  41.     }
  42. }
  43.  
  44. public void OnRoundStart(Handle event, const char[] name, bool dontBroadcast)
  45. {
  46.     for (int i = 0; i <= MAXPLAYERS; 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.  
  85. public Action OnPlayerDeath(Handle event, const char[] name, bool dontBroadcast)
  86. {
  87.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  88.     if(client == 0 || !IsClientInGame(client)) return;
  89.     int weapon = EntRefToEntIndex(g_PlayerSecondaryWeapons[client]);
  90.     if (weapon > 0)
  91.     {
  92.         char sWeapon[32];
  93.         int clip;
  94.         GetEdictClassname(weapon, sWeapon, 32);
  95.  
  96.         int index = CreateEntityByName(sWeapon);
  97.         float origin[3];
  98.         float ang[3];
  99.         if (strcmp(sWeapon, "weapon_melee") == 0)
  100.         {
  101.             char melee[156];
  102.             GetEntPropString(weapon , Prop_Data, "m_ModelName", melee, sizeof(melee));
  103.             for (int i = 0; i <= MAXLIST - 1; i++)
  104.             {
  105.                 if(strcmp(melee, Inflicted[i]) == 0)
  106.                 {
  107.                     ReplaceString(sWeapon, sizeof(sWeapon), "weapon_", "", false);
  108.                     DispatchKeyValue(index, "melee_script_name", sWeapon);
  109.                     break;
  110.                 }
  111.             }
  112.         }
  113.         else if (strcmp(sWeapon, "weapon_chainsaw") == 0)
  114.         {
  115.             clip = GetEntProp(weapon, Prop_Send, "m_iClip1");
  116.         }
  117.         else if (strcmp(sWeapon, "weapon_pistol") == 0 && (GetEntProp(weapon, Prop_Send, "m_isDualWielding") > 0))
  118.         {
  119.             int indexC = CreateEntityByName(sWeapon);
  120.             GetClientEyePosition(client,origin);
  121.             GetClientEyeAngles(client, ang);
  122.             GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
  123.             NormalizeVector(ang,ang);
  124.             ScaleVector(ang, 90.0);
  125.        
  126.             DispatchSpawn(indexC);
  127.             TeleportEntity(indexC, origin, NULL_VECTOR, ang);
  128.             ActivateEntity(indexC);
  129.         }
  130.         else if (strcmp(sWeapon, "weapon_pistol_magnum") == 0)
  131.         {
  132.             clip = GetEntProp(weapon, Prop_Send, "m_iClip1");
  133.         }
  134.  
  135.         RemovePlayerItem(client, weapon);
  136.         AcceptEntityInput(weapon, "kill");
  137.         GetClientEyePosition(client,origin);
  138.         GetClientEyeAngles(client, ang);
  139.         GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
  140.         NormalizeVector(ang,ang);
  141.         ScaleVector(ang, 90.0);
  142.        
  143.         DispatchSpawn(index);
  144.         TeleportEntity(index, origin, NULL_VECTOR, ang);
  145.         ActivateEntity(index);
  146.  
  147.         if (strcmp(sWeapon, "weapon_chainsaw") == 0 || strcmp(sWeapon, "weapon_pistol") == 0 || strcmp(sWeapon, "weapon_pistol_magnum") == 0)
  148.         {
  149.             SetEntProp(index, Prop_Send, "m_iClip1", clip);
  150.         }
  151.     }
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement