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

[TF2] Respawn Effects (3.2, 07/15/2017)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Mayor Gamer
Senior Member
Join Date: Nov 2012
Location: GetLocationOfUser(me);
Plugin ID:
5240
Plugin Version:
3.2
Plugin Category:
Fun Stuff
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
    45 
    Plugin Description:
    Adds particle effects when a player respawns. Team customizable. Now with donator support!
    Old 06-12-2016 , 18:50   [TF2] Respawn Effects (3.2, 07/15/2017)
    Reply With Quote #1

    [TF2] Respawn Effects



    Hello there! This is my first ever plugin i ever made in SourceMod. So don't flame me pls

    This plugin adds a particle effect when a player respawns along with a sound. It can be customized to have 2 different particles on each Team the player is (BLU and RED). It also has support for donators! You can use custom sounds too! That's all it's purpose.

    Be sure to leave suggestions and if there's a bug leave it below!


    ConVars
    Spoiler


    Overrides
    Spoiler


    Requirements
    • Sourcemod 1.7+

    Credits
    Quote:
    Part of the code has been provided by L. Duke to create temporary particle effects. Code can be found right here.
    Everything else was made by me!
    Changelog
    Quote:
    Version 3.2
    Spoiler

    Version 3.1
    Spoiler

    Version 3.0
    Spoiler

    Version 2.0
    Spoiler

    Version 1.0
    Spoiler
    Attached Files
    File Type: sp Get Plugin or Get Source (respawn_sfx.sp - 1839 views - 3.7 KB)
    File Type: smx respawn_sfx.smx (6.9 KB, 895 views)

    Last edited by Mayor Gamer; 07-15-2017 at 20:04. Reason: Update Version 3.2
    Mayor Gamer is offline
    Mayor Gamer
    Senior Member
    Join Date: Nov 2012
    Location: GetLocationOfUser(me);
    Old 06-13-2016 , 18:31   Re: [TF2] Respawn Effects (2.0, 06/12/2016)
    Reply With Quote #2

    -Reserved
    __________________
    Mayor Gamer is offline
    crafting
    Senior Member
    Join Date: May 2014
    Location: Somewhere on Earth
    Old 06-17-2016 , 19:12   Re: [TF2] Respawn Effects (2.0, 06/12/2016)
    Reply With Quote #3

    This looks cool. One question: Can you add admin flags?

    I have a server and would love to be able to give my donators another cool perk!

    Last edited by crafting; 06-17-2016 at 19:34.
    crafting is offline
    Mayor Gamer
    Senior Member
    Join Date: Nov 2012
    Location: GetLocationOfUser(me);
    Old 06-18-2016 , 18:09   Re: [TF2] Respawn Effects (2.0, 06/12/2016)
    Reply With Quote #4

    Quote:
    Originally Posted by crafting View Post
    This looks cool. One question: Can you add admin flags?

    I have a server and would love to be able to give my donators another cool perk!
    Added donation support with version 3.0. Enjoy ;)
    __________________
    Mayor Gamer is offline
    xines
    Veteran Member
    Join Date: Aug 2013
    Location: Denmark
    Old 06-18-2016 , 20:05   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
    Reply With Quote #5

    Updated this to be fully 1.7 SourcePawn Transitional Syntax, also removed some unnecessary code.

    Considering this is your first plugin, Good job.

    PHP Code:
    #include <sourcemod>
    #include <tf2>
    #include <tf2_stocks>

    #define TEAM1    2
    #define TEAM2    3

    // ConVars
    ConVar g_hRedPart;
    ConVar g_hBluPart;
    ConVar g_hDonorPart;
    ConVar g_hSound;
    ConVar g_hDonorSound;

    public 
    Plugin myinfo =
    {
        
    name "[TF2] Respawn Effects",
        
    author "aIM",
        
    description "Adds a particle effect on players upon respawning.",
        
    version "3.0",
        
    url ""
    };

    public 
    void OnPluginStart()
    {
        
    HookEvent("player_spawn"PlayerSpawn);
        
    g_hRedPart CreateConVar("sm_rsfx_redparticle""teleportedin_red""Particle to use on RED players.");
        
    g_hBluPart CreateConVar("sm_rsfx_bluparticle""teleportedin_blue""Particle to use on BLU players.");
        
    g_hDonorPart CreateConVar("sm_rsfx_donorparticle""eotl_pyro_pool_explosion""Particle to use on donators.");
        
    g_hSound CreateConVar("sm_rsfx_sound""items/spawn_item.wav""Path to the sound played when someone respawns.");
        
    g_hDonorSound CreateConVar("sm_rsfx_donorsound""weapons/teleporter_send.wav""Path to the sound player when a donator respawns.");
    }

    public 
    Action PlayerSpawn(Event event, const char[] namebool dontBroadcast)
    {
        
    int user GetClientOfUserId(event.GetInt("userid"));
        
        
    char    hRedPart[70],
                
    hBluPart[70],
                
    hDonorPart[70],
                
    hSound[PLATFORM_MAX_PATH],
                
    hDonorSound[PLATFORM_MAX_PATH];
        
        
    GetConVarString(g_hRedParthRedPartsizeof(hRedPart));
        
    GetConVarString(g_hBluParthBluPartsizeof(hBluPart));
        
    GetConVarString(g_hDonorParthDonorPartsizeof(hDonorPart));
        
    GetConVarString(g_hSoundhSoundsizeof(hSound));
        
    GetConVarString(g_hDonorSoundhDonorSoundsizeof(hDonorSound));
        
    PrecacheSound(hSound);
        
    PrecacheSound(hDonorSound);

        if (
    CheckCommandAccess(user"respawnsfx_donator"ADMFLAG_RESERVATION))
        {
            
    AttachParticle(userhDonorPart4.0);
            
    EmitSoundToClient(userhDonorSound);
        }
        else
        {
            switch (
    GetClientTeam(user))
            {
                case 
    TEAM1
                {
                    
    AttachParticle(userhRedPart2.5);
                    
    EmitSoundToClient(userhSound);
                }
                case 
    TEAM2
                {
                    
    AttachParticle(userhBluPart2.5);
                    
    EmitSoundToClient(userhSound);
                }
            }
        }
        
        return 
    Plugin_Continue;
    }

    stock void AttachParticle(int entchar[] particleTypefloat time)
    {
        
    int particle CreateEntityByName("info_particle_system");
        if (
    IsValidEntity(particle))
        {
            
    char tName[32];
            
    float pos[3];
            
    GetEntPropVector(entProp_Send"m_vecOrigin"pos);
            
    TeleportEntity(particleposNULL_VECTORNULL_VECTOR);
            
    GetEntPropString(entProp_Data"m_iName"tNamesizeof(tName));
            
    DispatchKeyValue(particle"targetname""tf2particle");
            
    DispatchKeyValue(particle"parentname"tName);
            
    DispatchKeyValue(particle"effect_name"particleType);
            
    DispatchSpawn(particle);
            
    SetVariantString(tName);
            
    AcceptEntityInput(particle"SetParent"particleparticle0);
            
    ActivateEntity(particle);
            
    AcceptEntityInput(particle"start");
            
    CreateTimer(timeDeleteParticlesparticle);
        }
        else
        {
            
    LogError("[Respawn SFX] Particle System failed to create (Missing Particle Name/Doesn't Exist)");
        }
    }

    public 
    Action DeleteParticles(Handle timerany particle)
    {
        if (
    IsValidEntity(particle))
        {
            
    char classname[64];
            
    GetEntityClassname(particleclassnamesizeof(classname));
            if (
    StrEqual(classname"info_particle_system"false))
            {
                
    AcceptEntityInput(particle"Kill");
            }
        }

    __________________
    xines is offline
    crafting
    Senior Member
    Join Date: May 2014
    Location: Somewhere on Earth
    Old 06-18-2016 , 20:55   Re: [TF2] Respawn Effects (2.0, 06/12/2016)
    Reply With Quote #6

    Quote:
    Originally Posted by Mayor Gamer View Post
    Added donation support with version 3.0. Enjoy ;)
    Well, I was talking more like.... only donators have respawn effects. But still having the option for donators having a different effect (and sound) is still good.

    Last edited by crafting; 06-18-2016 at 20:56.
    crafting is offline
    Mayor Gamer
    Senior Member
    Join Date: Nov 2012
    Location: GetLocationOfUser(me);
    Old 06-18-2016 , 21:56   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
    Reply With Quote #7

    Quote:
    Originally Posted by xines View Post
    Updated this to be fully 1.7 SourcePawn Transitional Syntax, also removed some unnecessary code.

    Considering this is your first plugin, Good job.

    PHP Code:
    #include <sourcemod>
    #include <tf2>
    #include <tf2_stocks>

    #define TEAM1    2
    #define TEAM2    3

    // ConVars
    ConVar g_hRedPart;
    ConVar g_hBluPart;
    ConVar g_hDonorPart;
    ConVar g_hSound;
    ConVar g_hDonorSound;

    public 
    Plugin myinfo =
    {
        
    name "[TF2] Respawn Effects",
        
    author "aIM",
        
    description "Adds a particle effect on players upon respawning.",
        
    version "3.0",
        
    url ""
    };

    public 
    void OnPluginStart()
    {
        
    HookEvent("player_spawn"PlayerSpawn);
        
    g_hRedPart CreateConVar("sm_rsfx_redparticle""teleportedin_red""Particle to use on RED players.");
        
    g_hBluPart CreateConVar("sm_rsfx_bluparticle""teleportedin_blue""Particle to use on BLU players.");
        
    g_hDonorPart CreateConVar("sm_rsfx_donorparticle""eotl_pyro_pool_explosion""Particle to use on donators.");
        
    g_hSound CreateConVar("sm_rsfx_sound""items/spawn_item.wav""Path to the sound played when someone respawns.");
        
    g_hDonorSound CreateConVar("sm_rsfx_donorsound""weapons/teleporter_send.wav""Path to the sound player when a donator respawns.");
    }

    public 
    Action PlayerSpawn(Event event, const char[] namebool dontBroadcast)
    {
        
    int user GetClientOfUserId(event.GetInt("userid"));
        
        
    char    hRedPart[70],
                
    hBluPart[70],
                
    hDonorPart[70],
                
    hSound[PLATFORM_MAX_PATH],
                
    hDonorSound[PLATFORM_MAX_PATH];
        
        
    GetConVarString(g_hRedParthRedPartsizeof(hRedPart));
        
    GetConVarString(g_hBluParthBluPartsizeof(hBluPart));
        
    GetConVarString(g_hDonorParthDonorPartsizeof(hDonorPart));
        
    GetConVarString(g_hSoundhSoundsizeof(hSound));
        
    GetConVarString(g_hDonorSoundhDonorSoundsizeof(hDonorSound));
        
    PrecacheSound(hSound);
        
    PrecacheSound(hDonorSound);

        if (
    CheckCommandAccess(user"respawnsfx_donator"ADMFLAG_RESERVATION))
        {
            
    AttachParticle(userhDonorPart4.0);
            
    EmitSoundToClient(userhDonorSound);
        }
        else
        {
            switch (
    GetClientTeam(user))
            {
                case 
    TEAM1
                {
                    
    AttachParticle(userhRedPart2.5);
                    
    EmitSoundToClient(userhSound);
                }
                case 
    TEAM2
                {
                    
    AttachParticle(userhBluPart2.5);
                    
    EmitSoundToClient(userhSound);
                }
            }
        }
        
        return 
    Plugin_Continue;
    }

    stock void AttachParticle(int entchar[] particleTypefloat time)
    {
        
    int particle CreateEntityByName("info_particle_system");
        if (
    IsValidEntity(particle))
        {
            
    char tName[32];
            
    float pos[3];
            
    GetEntPropVector(entProp_Send"m_vecOrigin"pos);
            
    TeleportEntity(particleposNULL_VECTORNULL_VECTOR);
            
    GetEntPropString(entProp_Data"m_iName"tNamesizeof(tName));
            
    DispatchKeyValue(particle"targetname""tf2particle");
            
    DispatchKeyValue(particle"parentname"tName);
            
    DispatchKeyValue(particle"effect_name"particleType);
            
    DispatchSpawn(particle);
            
    SetVariantString(tName);
            
    AcceptEntityInput(particle"SetParent"particleparticle0);
            
    ActivateEntity(particle);
            
    AcceptEntityInput(particle"start");
            
    CreateTimer(timeDeleteParticlesparticle);
        }
        else
        {
            
    LogError("[Respawn SFX] Particle System failed to create (Missing Particle Name/Doesn't Exist)");
        }
    }

    public 
    Action DeleteParticles(Handle timerany particle)
    {
        if (
    IsValidEntity(particle))
        {
            
    char classname[64];
            
    GetEntityClassname(particleclassnamesizeof(classname));
            if (
    StrEqual(classname"info_particle_system"false))
            {
                
    AcceptEntityInput(particle"Kill");
            }
        }

    Thanks a lot

    Quote:
    Originally Posted by crafting View Post
    Well, I was talking more like.... only donators have respawn effects. But still having the option for donators having a different effect (and sound) is still good.
    Well, i could make a convar to disable normal respawns but that's dumb.
    __________________
    Mayor Gamer is offline
    ddhoward
    Veteran Member
    Join Date: May 2012
    Location: California
    Old 06-18-2016 , 22:41   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
    Reply With Quote #8

    You could just leave the cvars blank? Or would this cause runtime errors? (i haven't read the code at all)

    Also, THANK YOU for doing it properly and using an override to specify who is and is not a donator.
    __________________

    Last edited by ddhoward; 06-18-2016 at 22:42.
    ddhoward is offline
    Mayor Gamer
    Senior Member
    Join Date: Nov 2012
    Location: GetLocationOfUser(me);
    Old 06-19-2016 , 02:56   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
    Reply With Quote #9

    Quote:
    Originally Posted by ddhoward View Post
    You could just leave the cvars blank? Or would this cause runtime errors? (i haven't read the code at all)

    Also, THANK YOU for doing it properly and using an override to specify who is and is not a donator.
    Thanks man! I tought of the override since it would not be nice for people who want to mess with the feature a bit.

    Nah, I won't leave them blank. It won't cause runtime errors but there has to be a default for them ;)

    Again thanks for the feedback
    __________________
    Mayor Gamer is offline
    ddhoward
    Veteran Member
    Join Date: May 2012
    Location: California
    Old 06-19-2016 , 03:05   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
    Reply With Quote #10

    No, I mean the server operator who wants to have no respawn effect for regular users can make the cvar blank on his end.
    __________________

    Last edited by ddhoward; 06-19-2016 at 03:06.
    ddhoward 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 06:00.


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