View Single Post
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