Senior Member
Join Date: Nov 2012
Location: GetLocationOfUser(me);
|
06-18-2016
, 21:56
Re: [TF2] Respawn Effects (3.0, 06/18/2016)
|
#7
|
Quote:
Originally Posted by xines
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[] name, bool dontBroadcast)
{
int user = GetClientOfUserId(event.GetInt("userid"));
char hRedPart[70],
hBluPart[70],
hDonorPart[70],
hSound[PLATFORM_MAX_PATH],
hDonorSound[PLATFORM_MAX_PATH];
GetConVarString(g_hRedPart, hRedPart, sizeof(hRedPart));
GetConVarString(g_hBluPart, hBluPart, sizeof(hBluPart));
GetConVarString(g_hDonorPart, hDonorPart, sizeof(hDonorPart));
GetConVarString(g_hSound, hSound, sizeof(hSound));
GetConVarString(g_hDonorSound, hDonorSound, sizeof(hDonorSound));
PrecacheSound(hSound);
PrecacheSound(hDonorSound);
if (CheckCommandAccess(user, "respawnsfx_donator", ADMFLAG_RESERVATION))
{
AttachParticle(user, hDonorPart, 4.0);
EmitSoundToClient(user, hDonorSound);
}
else
{
switch (GetClientTeam(user))
{
case TEAM1:
{
AttachParticle(user, hRedPart, 2.5);
EmitSoundToClient(user, hSound);
}
case TEAM2:
{
AttachParticle(user, hBluPart, 2.5);
EmitSoundToClient(user, hSound);
}
}
}
return Plugin_Continue;
}
stock void AttachParticle(int ent, char[] particleType, float time)
{
int particle = CreateEntityByName("info_particle_system");
if (IsValidEntity(particle))
{
char tName[32];
float pos[3];
GetEntPropVector(ent, Prop_Send, "m_vecOrigin", pos);
TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
GetEntPropString(ent, Prop_Data, "m_iName", tName, sizeof(tName));
DispatchKeyValue(particle, "targetname", "tf2particle");
DispatchKeyValue(particle, "parentname", tName);
DispatchKeyValue(particle, "effect_name", particleType);
DispatchSpawn(particle);
SetVariantString(tName);
AcceptEntityInput(particle, "SetParent", particle, particle, 0);
ActivateEntity(particle);
AcceptEntityInput(particle, "start");
CreateTimer(time, DeleteParticles, particle);
}
else
{
LogError("[Respawn SFX] Particle System failed to create (Missing Particle Name/Doesn't Exist)");
}
}
public Action DeleteParticles(Handle timer, any particle)
{
if (IsValidEntity(particle))
{
char classname[64];
GetEntityClassname(particle, classname, sizeof(classname));
if (StrEqual(classname, "info_particle_system", false))
{
AcceptEntityInput(particle, "Kill");
}
}
}
|
Thanks a lot
Quote:
Originally Posted by crafting
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.
__________________
|
|