This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[CSS] Spark effect on player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-27-2009 , 06:23   [CSS] Spark effect on player
Reply With Quote #1

I was trying to implement this ES code in sourcemod
Code:
        cmdFormat = 'es_xgive %s env_spark; ' % attacker
        cmdFormat += 'es_xfire %s env_spark SetParent !activator; ' % attacker
        cmdFormat += 'es_xfire %s env_spark AddOutput "spawnflags 896"; ' % attacker
        cmdFormat += 'es_xfire %s env_spark AddOutput "angles -90 0 0"; ' % attacker
        cmdFormat += 'es_xfire %s env_spark AddOutput "magnitude 8"; ' % attacker
        cmdFormat += 'es_xfire %s env_spark AddOutput "traillength 3"; ' % attacker
        cmdFormat += 'es_xfire %s env_spark StartSpark' % attacker
        es.server.queuecmd(cmdFormat)
That's how i was doing that
Code:
        new String:target[128];
        Format(target, sizeof(target), "target%i", client);
        DispatchKeyValue(client, "targetname", target);
        
        // And even so
        // new String:targetString[128];
        // Format(targetString, sizeof(targetString), "targetname %s", target);
        // SetVariantString(targetString);
        // AcceptEntityInput(client, "AddOutput");
                
        entSpark = CreateEntityByName("env_spark");
        DispatchKeyValue(entSpark, "spawnflags", "896");
        DispatchKeyValue(entSpark, "angles", "-90 0 0");
        DispatchKeyValue(entSpark, "magnitude", "8");
        DispatchKeyValue(entSpark, "traillength", "3");
        // And even so
        // DispatchKeyValue(entSpark, "parentname", target);
        DispatchSpawn(entSpark);
        
        SetVariantString(target);
        AcceptEntityInput(client, "SetParent");
        
        AcceptEntityInput(entSpark, "StartSpark");

        // And even so
        // AcceptEntityInput(entSpark, "StartSpark", client, client);
And it does not work
__________________
altex is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 12-27-2009 , 17:10   Re: [CSS] Spark effect on player
Reply With Quote #2

In Source mod & AMxmodx you have to use a Temporary Entity to create those kind of effects, it's gotten allot easier since sorucemod, you used to have to write out 20 lines of code every time, now there are these nice functions to do ti for you.

http://wiki.alliedmods.net/TempEnts_...eMod_SDKTools)
__________________
Peoples Army is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-28-2009 , 05:33   Re: [CSS] Spark effect on player
Reply With Quote #3

I was thinking about it. Thanks.
I think it will realy help.
But i've got one question, how to attack sparks effect to the player for making it moving with it?
__________________
altex is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 12-28-2009 , 06:00   Re: [CSS] Spark effect on player
Reply With Quote #4

Create repeatable timer with something like this:
PHP Code:
decl Float:fPos[3];
GetClientAbsOrigin(clientfPos);
TE_SetupSparks(fPosdirMagnitudeTrailLength);
TE_SendToAll(); 
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-28-2009 , 06:13   Re: [CSS] Spark effect on player
Reply With Quote #5

Quote:
Originally Posted by exvel View Post
Create repeatable timer with something like this:
PHP Code:
decl Float:fPos[3];
GetClientAbsOrigin(clientfPos);
TE_SetupSparks(fPosdirMagnitudeTrailLength);
TE_SendToAll(); 
Yes, i was thinking about it, but it's not optimal solution.
I realy do not want to create many entities, if i just can create one.
__________________
altex is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 12-28-2009 , 08:26   Re: [CSS] Spark effect on player
Reply With Quote #6

Those are temp entities. There are very fast and not harmful for server cpu.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-28-2009 , 09:16   Re: [CSS] Spark effect on player
Reply With Quote #7

Quote:
Originally Posted by exvel View Post
Those are temp entities. There are very fast and not harmful for server cpu.
I understand you completely Thanks again. But.
A realy, realy do not want to create entities, and i only want to move one entity with the player. Just like it implemented in eventscripts. And i do not understand why it is not possible in sourcemod ))

I just can not allow myself as a programmer to create many entities if i just need one )) I hope you understant my problem.
__________________
altex is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 12-28-2009 , 11:19   Re: [CSS] Spark effect on player
Reply With Quote #8

Its a temporary entity, the entity will kill itself as soon as the message is done
__________________
Peoples Army is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-28-2009 , 11:37   Re: [CSS] Spark effect on player
Reply With Quote #9

Quote:
Originally Posted by Peoples Army View Post
Its a temporary entity, the entity will kill itself as soon as the message is done
what message?

i want to kill that entity by timer or provide time to live , i dont want entity to be killed in very short time.

For example, there is a player, and i want that for 10 seconds there will be sparks under his feet. So i want to create sparks entity once, than move it with player, that kill that entity after 10 seconds left. Engine provides functionality to move that entity with player automaticaly, and to spark all that time, not just once. So that is what i'm going to implement.
__________________
altex is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-28-2009 , 16:57   Re: [CSS] Spark effect on player
Reply With Quote #10

I DID IT ! WOW!

Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

public Plugin:myinfo =
{
    name = "Test2",
    author = "Otstrel.ru Team",
    description = "Test2",
    version = "1",
    url = "http://otstrel.ru"
};

new g_sparks[MAXPLAYERS+1] = {-1, ...};

public OnPluginStart()
{
    HookEvent("weapon_fire", _WeaponFire);
    HookEvent("player_death", _PD);
}

public _WeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    
    if ( start(client) )
    {
        CreateTimer(10.0, Timer_Spark, client);
    }
}

public _PD(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    stop(client);
}

start(client)
{
    if ( g_sparks[client]  > -1 )
    {
        return 0;
    }
    
    decl Float:fPos[3];
    GetClientAbsOrigin(client, fPos);
    
    new String:target[128];
    Format(target, sizeof(target), "target%i", client);
    DispatchKeyValue(client, "targetname", target);
        
    new entSpark = CreateEntityByName("env_spark");
    DispatchKeyValue(entSpark, "spawnflags", "896");
    DispatchKeyValue(entSpark, "angles", "-90 0 0");
    DispatchKeyValue(entSpark, "magnitude", "8");
    DispatchKeyValue(entSpark, "traillength", "3");
    DispatchSpawn(entSpark);
            
    SetEntPropVector(entSpark, Prop_Send, "m_vecOrigin", fPos);

    SetVariantString(target);
    AcceptEntityInput(entSpark, "SetParent");
        
    AcceptEntityInput(entSpark, "StartSpark");
    g_sparks[client] = entSpark;
    
    return 1;
}

stop(client)
{
    if ( g_sparks[client] < 0 )
    {
        return;
    }
    AcceptEntityInput(g_sparks[client], "StopSpark");
    AcceptEntityInput(g_sparks[client], "Kill");
    g_sparks[client] = -1;
}


public Action:Timer_Spark(Handle:timer, any:client)
{
    stop(client);
}
But i dont think this effect is a good enough for me )) I need something more expressive...
especialy in the first 10 second this effect looks like small light (( almost without sparks.
__________________

Last edited by altex; 12-28-2009 at 19:15.
altex is offline
Reply



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 19:55.


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