Don't use a global variable for effect. Instead, pass its entity index as part of the timer. Like this:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
public Plugin:myinfo = {
name = "effect particle",
author = "Skuzy",
description = " ",
version = " ",
url = " "
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3])
{
new particle = CreateEntityByName("info_particle_system");
new Float:Origine[3];
GetEntPropVector(victim, Prop_Send, "m_vecOrigin", Origine);
TeleportEntity(particle, Origine, NULL_VECTOR, NULL_VECTOR);
DispatchKeyValue(particle, "effect_name", "water_splash_02_animated");
DispatchKeyValue(particle, "targetname", "particle");
DispatchSpawn(particle);
ActivateEntity(particle);
AcceptEntityInput(particle, "Start");
CreateTimer(1.0,stop_effect, EntIndexToEntRef(particle));
}
public Action:stop_effect(Handle:timer, any:particleRef)
{
new particle = EntRefToEntIndex(particleRef);
if (particle > MaxClients)
{
stop(particle);
}
}
stop(particle)
{
AcceptEntityInput(particle, "Stop");
AcceptEntityInput(particle, "Kill");
}
The particle is being passed as a reference here in case the entity is removed before the timer is called.
__________________