Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- #include <cstrike>
- int g_unClientSprite[MAXPLAYERS+1] = INVALID_ENT_REFERENCE;
- bool IsHaveSprite[MAXPLAYERS+1] = false;
- public Plugin myinfo =
- {
- name = "Icons for Gangs",
- author = "Nano",
- description = "",
- version = "2.2",
- url = "http://steamcommunity.com/id/marianzet1"
- };
- public void OnPluginStart()
- {
- HookEvent("round_start", round_start);
- HookEvent("player_death", Event_PlayerDeath);
- HookEvent("round_end", round_end);
- }
- public void OnMapStart()
- {
- AddFileToDownloadsTable("materials/decals/rage/pandilla.vtf");
- AddFileToDownloadsTable("materials/decals/rage/pandilla.vmt");
- PrecacheModel("materials/decals/rage/pandilla.vmt", true);
- for (int i = 1; i <= MaxClients; i++)
- {
- if(IsValidClient(i))
- {
- IsHaveSprite[i] = false;
- }
- }
- }
- public void OnClientConnected(int client)
- {
- if(g_unClientSprite[client] != INVALID_ENT_REFERENCE)
- {
- g_unClientSprite[client] = INVALID_ENT_REFERENCE;
- }
- IsHaveSprite[client] = false;
- }
- public void OnClientDisconnect(int client)
- {
- if(g_unClientSprite[client] != INVALID_ENT_REFERENCE)
- {
- int entity = EntRefToEntIndex(g_unClientSprite[client]);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "kill");
- }
- g_unClientSprite[client] = INVALID_ENT_REFERENCE;
- }
- IsHaveSprite[client] = false;
- }
- public Action round_start(Event event, char[] name, bool dontBroadcast)
- {
- CreateTimer(1.0, Timer_SetSprite);
- }
- public Action round_end(Event event, char[] name, bool dontBroadcast)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if(IsValidClient(i))
- {
- if(IsHaveSprite[i])
- {
- int entity = EntRefToEntIndex(g_unClientSprite[i]);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "kill");
- }
- }
- IsHaveSprite[i] = false;
- }
- }
- }
- public Action Timer_SetSprite(Handle timer)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if(IsValidClient(i) && GetClientTeam(i) == CS_TEAM_T)
- {
- CreateSprite(i);
- }
- }
- }
- public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(event.GetInt("userid"));
- if (client > 0 && IsValidClient(client))
- {
- int entity = EntRefToEntIndex(g_unClientSprite[client]);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "kill");
- }
- }
- return Plugin_Continue;
- }
- public CreateSprite(client)
- {
- if(g_unClientSprite[client] != INVALID_ENT_REFERENCE)
- return;
- if(IsHaveSprite[client])
- return;
- new m_unEnt = CreateEntityByName("env_sprite");
- if (IsValidEntity(m_unEnt))
- {
- char vName[32];
- GetClientName(client, vName, sizeof(vName));
- Format(vName, sizeof(vName), "Sprite_%d", client);
- DispatchKeyValue(client, "targetname", vName);
- float m_flPosition[3];
- GetClientEyePosition(client, m_flPosition);
- m_flPosition[2] += 20.0;
- DispatchKeyValue(m_unEnt, "model", "materials/decals/rage/pandilla.vmt");
- DispatchKeyValue(m_unEnt, "classname", "env_sprite");
- DispatchKeyValue(m_unEnt, "spawnflags", "1");
- DispatchKeyValue(m_unEnt, "scale", "0.1");
- DispatchKeyValue(m_unEnt, "rendermode", "1");
- DispatchKeyValue(m_unEnt, "rendercolor", "255 255 255");
- DispatchSpawn(m_unEnt);
- TeleportEntity(m_unEnt, m_flPosition, NULL_VECTOR, NULL_VECTOR);
- SetVariantString(vName);
- AcceptEntityInput(m_unEnt, "SetParent", client, m_unEnt, 0);
- Format(vName, sizeof(vName), "%N", client);
- DispatchKeyValue(client, "targetname", vName);
- g_unClientSprite[client] = EntIndexToEntRef(m_unEnt);
- IsHaveSprite[client] = true;
- }
- }
- bool IsValidClient(int client)
- {
- return (0 < client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement