Hey, I've made a small and basic CS:GO gore plug-in that enhances the blood when a player is killed by a head shot for a personal game server.
I took things from
CS:GO Goremod.
My questions are the next ones.
Is the Force Precaching OK and really required (at OnMapStart)?
Is the entity removal way OK?
Is the blood particle creation OK? The way I am using DispatchKeyValue, DispatchSpawn, ActivateEntity and AcceptEntityInput?
With much thanks.
PHP Code:
#include <sourcemod>
#include <sdktools>
public OnPluginStart() {
HookEvent("player_death", OnPlayerDeath);
}
public OnMapStart() {
PrecacheParticle("blood_impact_heavy");
PrecacheParticle("blood_impact_goop_heavy");
PrecacheParticle("blood_impact_red_01_chunk");
PrecacheParticle("blood_impact_headshot_01c");
PrecacheParticle("blood_impact_headshot_01b");
PrecacheParticle("blood_impact_headshot_01d");
PrecacheParticle("blood_impact_basic");
PrecacheParticle("blood_impact_medium");
PrecacheParticle("blood_impact_red_01_goop_a");
PrecacheParticle("blood_impact_red_01_goop_b");
PrecacheParticle("blood_impact_goop_medium");
PrecacheParticle("blood_impact_red_01_goop_c");
PrecacheParticle("blood_impact_red_01_drops");
PrecacheParticle("blood_impact_drops1");
PrecacheParticle("blood_impact_red_01_backspray");
}
public OnPlayerDeath(Handle:pEvent, const String:EventName[], bool:NoBroadcast) {
static Client, Iterator;
if (GetEventBool(pEvent, "headshot")) {
Client = GetClientOfUserId(GetEventInt(pEvent, "userid"));
for (Iterator = 0; Iterator < 3; Iterator++) {
CreateParticle(Client, "blood_impact_red_01_backspray");
CreateParticle(Client, "blood_impact_drops1");
CreateParticle(Client, "blood_impact_red_01_drops");
}
CreateParticle(Client, "blood_impact_red_01_goop_c");
CreateParticle(Client, "blood_impact_goop_medium");
CreateParticle(Client, "blood_impact_red_01_goop_b");
CreateParticle(Client, "blood_impact_red_01_goop_a");
CreateParticle(Client, "blood_impact_medium");
CreateParticle(Client, "blood_impact_basic");
CreateParticle(Client, "blood_impact_heavy");
CreateParticle(Client, "blood_impact_goop_heavy");
CreateParticle(Client, "blood_impact_red_01_chunk");
CreateParticle(Client, "blood_impact_headshot_01c");
CreateParticle(Client, "blood_impact_headshot_01b");
CreateParticle(Client, "blood_impact_headshot_01d");
}
}
public Action:KillParticle(Handle:pTimer, Particle) {
AcceptEntityInput(Particle, "kill");
}
SpawnParticle(Particle, String:Name[]) {
DispatchKeyValue(Particle, "effect_name", Name);
DispatchSpawn(Particle);
ActivateEntity(Particle);
AcceptEntityInput(Particle, "start");
}
PrecacheParticle(String:Name[]) {
static Particle;
Particle = CreateEntityByName("info_particle_system");
if (Particle != INVALID_ENT_REFERENCE) {
SpawnParticle(Particle, Name);
CreateTimer(1.0, KillParticle, Particle, TIMER_FLAG_NO_MAPCHANGE);
}
}
CreateParticle(Client, String:Name[]) {
static Float:Origin[3], Particle;
Particle = CreateEntityByName("info_particle_system");
if (Particle != INVALID_ENT_REFERENCE) {
GetEntPropVector(Client, Prop_Send, "m_vecOrigin", Origin);
Origin[2] += GetRandomFloat(5.0, 30.0);
TeleportEntity(Particle, Origin, NULL_VECTOR, NULL_VECTOR);
SpawnParticle(Particle, Name);
CreateTimer(1.0, KillParticle, Particle, TIMER_FLAG_NO_MAPCHANGE);
}
}
__________________