AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [TF2] Respawn Effects (3.2, 07/15/2017) (https://forums.alliedmods.net/showthread.php?t=283852)

Mayor Gamer 06-12-2016 18:50

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



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

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


Mayor Gamer 06-13-2016 18:31

Re: [TF2] Respawn Effects (2.0, 06/12/2016)
 
-Reserved

crafting 06-17-2016 19:12

Re: [TF2] Respawn Effects (2.0, 06/12/2016)
 
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!

Mayor Gamer 06-18-2016 18:09

Re: [TF2] Respawn Effects (2.0, 06/12/2016)
 
Quote:

Originally Posted by crafting (Post 2428424)
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 ;)

xines 06-18-2016 20:05

Re: [TF2] Respawn Effects (3.0, 06/18/2016)
 
Updated this to be fully 1.7 SourcePawn Transitional Syntax, also removed some unnecessary code.

Considering this is your first plugin, Good job. :up:

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");
        }
    }



crafting 06-18-2016 20:55

Re: [TF2] Respawn Effects (2.0, 06/12/2016)
 
Quote:

Originally Posted by Mayor Gamer (Post 2428666)
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.

Mayor Gamer 06-18-2016 21:56

Re: [TF2] Respawn Effects (3.0, 06/18/2016)
 
Quote:

Originally Posted by xines (Post 2428691)
Updated this to be fully 1.7 SourcePawn Transitional Syntax, also removed some unnecessary code.

Considering this is your first plugin, Good job. :up:

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 (Post 2428704)
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.

ddhoward 06-18-2016 22:41

Re: [TF2] Respawn Effects (3.0, 06/18/2016)
 
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.

Mayor Gamer 06-19-2016 02:56

Re: [TF2] Respawn Effects (3.0, 06/18/2016)
 
Quote:

Originally Posted by ddhoward (Post 2428713)
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 :)

ddhoward 06-19-2016 03:05

Re: [TF2] Respawn Effects (3.0, 06/18/2016)
 
No, I mean the server operator who wants to have no respawn effect for regular users can make the cvar blank on his end.


All times are GMT -4. The time now is 17:10.

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