Ooh, this could very easily be turned into a Basic Donator Interface-using Donator plugin. And I think that's exactly what I'll do (credit will be given to MasterXykon of course)
EDIT: Tested this out ingame, not happy that the particle spawns at the players feet. I did have code lying around for attaching particles to the players back (just behind their head). I'm gonna look for it and see what I can do.
EDIT 2: So I found the code, turns out it's from Noodleboy347's old Premium Mod plugin. I'm recoding this plugin right now so that you can only equip one sparkle effect (which eliminates that glitch where you can equip numerous effects, but can't remove them all), and also adding in separate commands, one for a normal particle attachment, and one for at the head.
EDIT 3: Ok so here's what I've come up with. I haven't quite yet tested it ingame, but it should work much better, detecting if you already have a sparkle effect, not creating a new one if you do, etc.
Just some tips for you though, MasterXykon:
1. You don't need to do individual #define's for "PLUGIN_AUTHOR", "PLUGIN_DESCRIPTION", etc. You only really need to define the PLUGIN_VERSION, for the version ConVar which you need to add in order for this plugin to be approved. In the code below, I've put an example of how the plugin version ConVar should look.
2. You should use my "g_Sparkled" setup in the future, as it allows you to set a "flag" of sorts on the player. As well, you need OnClientDisconnect to tell the game to delete the particle, if the player has a particle.
3. You were missing "#pragma semicolon 1", which means you need to close things off with ;
4. My example below uses a timer setup. That's because the code I used from noodleboy's Premium Mod was built to use a timer. I should've recoded your particle creation/removal code to make a non-timer-using version, but I forgot about it
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>
#include <clientprefs>
#pragma semicolon 1
#define NO_ATTACH 0
#define ATTACH_NORMAL 1
#define ATTACH_HEAD 2
new bool:g_Sparkled[MAXPLAYERS+1];
#define PLUGIN_VERSION "1.00"
public Plugin:myinfo =
{
name = "[TF2] Sparkles",
author = "Master Xykon",
description = "Adds Community Sparkle trails",
version = PLUGIN_VERSION
};
public OnPluginStart()
{
CreateConVar("sm_sparkletrail_version", PLUGIN_VERSION, "Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
RegConsoleCmd("sm_sparkle1", SparkleNormal, "Become Sparkly");
RegConsoleCmd("sm_sparkle2", SparkleHead, "Become Sparkly");
RegConsoleCmd("sm_sparkle_off", SparkleOff, "Remove Sparkly");
}
public OnClientDisconnect(client)
{
if(g_Sparkled[client] == true)
{
DeleteParticle(particle);
g_Sparkled[client] = false;
}
}
public Action:SparkleNormal(client, args)
{
if(g_Sparkled[client] == true)
{
PrintToChat(client, "[SM] Sorry, you've already been Sparkled!");
return Plugin_Handled;
}
else
{
CreateParticle("community_sparkle", 300.0, client, ATTACH_NORMAL);
g_Sparkled[client] = true;
}
}
public Action:SparkleHead(client, args)
{
if(g_Sparkled[client] == true)
{
PrintToChat(client, "[Sparkles] Sorry, you've already been Self-Made!");
return Plugin_Handled;
}
else
{
CreateParticle("community_sparkle", 300.0, client, ATTACH_HEAD);
PrintToChat(client, "[Sparkles] You've been Self-Made'd!");
g_Sparkled[client] = true;
}
}
public Action:SparkleOff(client, args)
{
if (g_Sparkled[client] == true)
{
DeleteParticle(particle);
PrintToChat(client, "[Sparkles] Your Self-Made wore off!");
}
else
{
PrintToChat(client, "[Sparkles] Sorry, you're not Self-Made'd!");
}
return Plugin_Handled;
}
stock Handle:CreateParticle(String:type[], Float:time, entity, attach=NO_ATTACH, Float:xOffs=0.0, Float:yOffs=0.0, Float:zOffs=0.0)
{
new particle = CreateEntityByName("info_particle_system");
if (IsValidEdict(particle))
{
decl Float:pos[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
pos[0] += xOffs;
pos[1] += yOffs;
pos[2] += zOffs;
TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
DispatchKeyValue(particle, "effect_name", type);
if (attach != NO_ATTACH)
{
SetVariantString("!activator");
AcceptEntityInput(particle, "SetParent", entity, particle, 0);
if (attach == ATTACH_HEAD)
{
SetVariantString("head");
AcceptEntityInput(particle, "SetParentAttachmentMaintainOffset", particle, particle, 0);
}
}
DispatchKeyValue(particle, "targetname", "present");
DispatchSpawn(particle);
ActivateEntity(particle);
AcceptEntityInput(particle, "Start");
return CreateTimer(time, DeleteParticle, particle);
}
else
{
LogError("(CreateParticle): Could not create info_particle_system");
}
return INVALID_HANDLE;
}
public Action:DeleteParticle(handle:timer, any:particle)
{
if (IsValidEdict(particle))
{
new String:classname[64];
GetEdictClassname(particle, classname, sizeof(classname));
if (StrEqual(classname, "info_particle_system", false))
{
RemoveEdict(particle);
}
}
}