Raised This Month: $12 Target: $400
 3% 

stop effect mistake


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Miew
Member
Join Date: Jan 2014
Old 02-14-2014 , 09:49   stop effect mistake
Reply With Quote #1

i have a probleme with this :

i want to kill particle 1seconde after display effect but when few particle was create in same time the timer dont stop effect

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

new particle;

public 
Plugin:myinfo =  {
    
name "effect particle",
    
author "Skuzy",
    
description " ",
    
version " ",
    
url " "
}
 
public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{

    
particle CreateEntityByName("info_particle_system");
    
    new 
Float:Origine[3];
    
GetEntPropVector(victimProp_Send"m_vecOrigin"Origine);

    
TeleportEntity(particleOrigineNULL_VECTORNULL_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);
}

public 
Action:stop_effect(Handle:timerany:client)
{
    
stop(client);
}

stop(client)
{
    
AcceptEntityInput(particle"Stop");
    
AcceptEntityInput(particle"Kill");

Miew is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-14-2014 , 10:20   Re: stop effect mistake
Reply With Quote #2

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(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{

    new 
particle CreateEntityByName("info_particle_system");
    
    new 
Float:Origine[3];
    
GetEntPropVector(victimProp_Send"m_vecOrigin"Origine);

    
TeleportEntity(particleOrigineNULL_VECTORNULL_VECTOR);
    
DispatchKeyValue(particle"effect_name""water_splash_02_animated");
    
DispatchKeyValue(particle"targetname""particle");
    
DispatchSpawn(particle);
    
ActivateEntity(particle);
    
AcceptEntityInput(particle"Start");
    
CreateTimer(1.0,stop_effectEntIndexToEntRef(particle));
}

public 
Action:stop_effect(Handle:timerany: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.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 02-14-2014 at 10:22.
Powerlord is offline
Miew
Member
Join Date: Jan 2014
Old 02-14-2014 , 12:42   Re: stop effect mistake
Reply With Quote #3

thx i will try it ;)

EDIT: WORK perfectly thx ;p

Last edited by Miew; 02-14-2014 at 12:46.
Miew is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode