SHARE
TWEET

Untitled

FlacoBey Mar 21st, 2019 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdktools>
  5. #include <sdkhooks>
  6. #include <cstrike>
  7.  
  8. int g_unClientSprite[MAXPLAYERS+1] = INVALID_ENT_REFERENCE;
  9. bool IsHaveSprite[MAXPLAYERS+1] = false;
  10.  
  11. public Plugin myinfo =
  12. {
  13.     name = "Icons for Gangs",
  14.     author = "Nano",
  15.     description = "",
  16.     version = "2.2",
  17.     url = "http://steamcommunity.com/id/marianzet1"
  18. };
  19.  
  20. public void OnPluginStart()
  21. {
  22.     HookEvent("round_start", round_start);
  23.     HookEvent("player_death", Event_PlayerDeath);
  24.     HookEvent("round_end", round_end);
  25. }
  26.  
  27. public void OnMapStart()
  28. {
  29.     AddFileToDownloadsTable("materials/decals/rage/pandilla.vtf");
  30.     AddFileToDownloadsTable("materials/decals/rage/pandilla.vmt");
  31.     PrecacheModel("materials/decals/rage/pandilla.vmt", true);
  32.    
  33.     for (int i = 1; i <= MaxClients; i++)
  34.     {
  35.         if(IsValidClient(i))
  36.         {
  37.             IsHaveSprite[i] = false;
  38.         }
  39.     }
  40. }
  41.  
  42. public void OnClientConnected(int client)
  43. {
  44.     if(g_unClientSprite[client] != INVALID_ENT_REFERENCE)
  45.     {
  46.         g_unClientSprite[client] = INVALID_ENT_REFERENCE;
  47.     }
  48.     IsHaveSprite[client] = false;
  49. }
  50.  
  51. public void OnClientDisconnect(int client)
  52. {
  53.     if(g_unClientSprite[client] != INVALID_ENT_REFERENCE)
  54.     {
  55.         int entity = EntRefToEntIndex(g_unClientSprite[client]);
  56.         if(IsValidEntity(entity))
  57.         {
  58.             AcceptEntityInput(entity, "kill");
  59.         }
  60.         g_unClientSprite[client] = INVALID_ENT_REFERENCE;
  61.     }
  62.     IsHaveSprite[client] = false;
  63. }
  64.  
  65. public Action round_start(Event event, char[] name, bool dontBroadcast)
  66. {    
  67.     CreateTimer(1.0, Timer_SetSprite);
  68. }
  69.  
  70. public Action round_end(Event event, char[] name, bool dontBroadcast)
  71. {
  72.     for (int i = 1; i <= MaxClients; i++)
  73.     {
  74.         if(IsValidClient(i))
  75.         {
  76.             if(IsHaveSprite[i])
  77.             {
  78.                 int entity = EntRefToEntIndex(g_unClientSprite[i]);
  79.                 if(IsValidEntity(entity))
  80.                 {
  81.                     AcceptEntityInput(entity, "kill");
  82.                 }
  83.             }
  84.             IsHaveSprite[i] = false;
  85.         }
  86.     }
  87. }
  88.  
  89. public Action Timer_SetSprite(Handle timer)
  90. {
  91.     for (int i = 1; i <= MaxClients; i++)
  92.     {
  93.         if(IsValidClient(i) && GetClientTeam(i) == CS_TEAM_T)
  94.         {
  95.             CreateSprite(i);
  96.         }
  97.     }
  98. }
  99.  
  100. public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
  101. {
  102.     int client = GetClientOfUserId(event.GetInt("userid"));
  103.     if (client > 0 && IsValidClient(client))
  104.     {
  105.         int entity = EntRefToEntIndex(g_unClientSprite[client]);
  106.         if(IsValidEntity(entity))
  107.         {
  108.             AcceptEntityInput(entity, "kill");
  109.         }
  110.     }
  111.  
  112.     return Plugin_Continue;
  113. }
  114.  
  115. public CreateSprite(client)
  116. {
  117.     if(g_unClientSprite[client] != INVALID_ENT_REFERENCE)
  118.         return;
  119.    
  120.     if(IsHaveSprite[client])
  121.         return;
  122.    
  123.     new m_unEnt = CreateEntityByName("env_sprite");
  124.     if (IsValidEntity(m_unEnt))
  125.     {
  126.         char vName[32];
  127.         GetClientName(client, vName, sizeof(vName));
  128.  
  129.         Format(vName, sizeof(vName), "Sprite_%d", client);
  130.         DispatchKeyValue(client, "targetname", vName);
  131.  
  132.         float m_flPosition[3];
  133.         GetClientEyePosition(client, m_flPosition);
  134.         m_flPosition[2] += 20.0;
  135.         DispatchKeyValue(m_unEnt, "model", "materials/decals/rage/pandilla.vmt");
  136.         DispatchKeyValue(m_unEnt, "classname", "env_sprite");
  137.         DispatchKeyValue(m_unEnt, "spawnflags", "1");
  138.         DispatchKeyValue(m_unEnt, "scale", "0.1");
  139.         DispatchKeyValue(m_unEnt, "rendermode", "1");
  140.         DispatchKeyValue(m_unEnt, "rendercolor", "255 255 255");
  141.         DispatchSpawn(m_unEnt);
  142.         TeleportEntity(m_unEnt, m_flPosition, NULL_VECTOR, NULL_VECTOR);
  143.         SetVariantString(vName);
  144.         AcceptEntityInput(m_unEnt, "SetParent", client, m_unEnt, 0);
  145.        
  146.         Format(vName, sizeof(vName), "%N", client);
  147.         DispatchKeyValue(client, "targetname", vName);
  148.         g_unClientSprite[client] = EntIndexToEntRef(m_unEnt);
  149.         IsHaveSprite[client] = true;
  150.     }
  151. }
  152.  
  153.  
  154. bool IsValidClient(int client)
  155. {
  156.     return (0 < client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client));
  157. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top