Ok this is my first plugin ever and I know hardly anything but this what I have so far. I want to make a plugin that makes you the Horseless Headless Horsemann. So far what I have done is, it turns you into the Horseless model in civilian. I need help with attaching the axe to the model as well as making it walk normal and not civilian if possible. Again I know nothing but I think I have gotten pretty far. Here is my source code.
Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>
#define PL_VERSION "1.1"
#define NORMAL {255,255,255,255}
#define INVISI {255,255,255,0}
#define HHH "models/bots/headless_hatman.mdl"
#define HHHA "models/weapons/c_models/c_bigaxe/c_bigaxe.mdl"
new g_FilteredEntity = -1;
new bool:g_IsHHH[MAXPLAYERS+1] = { false, ...};
public Plugin:myinfo =
{
name = "[TF2] You Are HHH",
author = "GinXeng",
description = "Makes you the Horseless Headless Horsemann",
version = PL_VERSION,
url = "http://www.pcgametime.com"
}
public OnMapStart()
{
PrecacheModel("models/bots/headless_hatman.mdl");
PrecacheModel("models/weapons/c_models/c_bigaxe/c_bigaxe.mdl");
}
//SM CALLBACKS
public OnPluginStart()
{
LoadTranslations("common.phrases");
CreateConVar("sm_hhh_version", PL_VERSION, "", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY)
RegAdminCmd("sm_hhh", MakeMeAHHH, ADMFLAG_CHEATS);
HookEvent("post_inventory_application", EventInventoryApplication, EventHookMode_Post);
}
public EventInventoryApplication(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (IsValidEntity(client) && g_IsHHH[client])
{
SetVariantString("");
AcceptEntityInput(client, "SetCustomModel");
Colorize(client, NORMAL);
SetEntProp(client, Prop_Data, "m_takedamage", 2, 1)
g_IsHHH[client] = false;
PrintToChat(client, "\x04[\x03Horsemann\x04]\x01: Your Horsemann appearance has been removed!")
}
}
public Action:MakeMeAHHH(client, args)
{
if (client < 0)
{
ReplyToCommand(client, "Command must be used ingame!")
return Plugin_Handled;
}
if (IsPlayerAlive(client) && IsValidEntity(client) && !g_IsHHH[client])
{
SetVariantString(HHH);
AcceptEntityInput(client, "SetCustomModel");
SetVariantInt(1);
Colorize(client, INVISI);
SetEntProp(client, Prop_Data, "m_takedamage", 0, 1)
g_IsHHH[client] = true;
PrintToChat(client, "\x04[\x03Horsemann\x04]\x01: You now look just like the Horsemann!")
}
else if (IsValidEntity(client) && g_IsHHH[client])
{
SetVariantString("");
AcceptEntityInput(client, "SetCustomModel");
Colorize(client, NORMAL);
SetEntProp(client, Prop_Data, "m_takedamage", 2, 1)
g_IsHHH[client] = false;
PrintToChat(client, "\x04[\x03Horsemann\x04]\x01: Your Horsemann appearance has been removed!")
}
return Plugin_Handled;
}
public bool:AmmopackTraceFilter(ent, contentMask)
{
return (ent != g_FilteredEntity);
}
stock bool:IsEntLimitReached()
{
if (GetEntityCount() >= (GetMaxEntities()-16))
{
PrintToServer("Warning: Entity limit is nearly reached! Please switch or reload the map!");
LogError("Entity limit is nearly reached: %d/%d", GetEntityCount(), GetMaxEntities());
return true;
}
else
return false;
}
public Colorize(client, color[4])
{
//Colorize the weapons
new m_hMyWeapons = FindSendPropOffs("CBasePlayer", "m_hMyWeapons");
new String:classname[256];
new type;
new TFClassType:class = TF2_GetPlayerClass(client);
for(new i = 0, weapon; i < 47; i += 4)
{
weapon = GetEntDataEnt2(client, m_hMyWeapons + i);
if(weapon > -1 )
{
GetEdictClassname(weapon, classname, sizeof(classname));
if((StrContains(classname, "tf_weapon_",false) >= 0))
{
SetEntityRenderMode(weapon, RENDER_TRANSCOLOR);
SetEntityRenderColor(weapon, color[0], color[1], color[2], color[3]);
}
}
}
//Colorize the wearables, such as hats
SetWearablesRGBA_Impl( client, "tf_wearable_item", "CTFWearableItem",color );
SetWearablesRGBA_Impl( client, "tf_wearable_item_demoshield", "CTFWearableItemDemoShield", color);
//Colorize the player
//SetEntityRenderMode(client, RENDER_TRANSCOLOR);
//SetEntityRenderColor(client, color[0], color[1], color[2], color[3]);
if(color[3] > 0)
type = 1;
InvisibleHideFixes(client, class, type);
return;
}
SetWearablesRGBA_Impl( client, const String:entClass[], const String:serverClass[], color[4])
{
new ent = -1;
while( (ent = FindEntityByClassname(ent, entClass)) != -1 )
{
if ( IsValidEntity(ent) )
{
if (GetEntDataEnt2(ent, FindSendPropOffs(serverClass, "m_hOwnerEntity")) == client)
{
SetEntityRenderMode(ent, RENDER_TRANSCOLOR);
SetEntityRenderColor(ent, color[0], color[1], color[2], color[3]);
}
}
}
}
InvisibleHideFixes(client, TFClassType:class, type)
{
if(class == TFClass_DemoMan)
{
new decapitations = GetEntProp(client, Prop_Send, "m_iDecapitations");
if(decapitations >= 1)
{
if(!type)
{
//Removes Glowing Eye
}
else
{
//Add Glowing Eye
}
}
}
else if(class == TFClass_Spy)
{
new disguiseWeapon = GetEntPropEnt(client, Prop_Send, "m_hDisguiseWeapon");
if(IsValidEntity(disguiseWeapon))
{
if(!type)
{
SetEntityRenderMode(disguiseWeapon , RENDER_TRANSCOLOR);
new color[4] = INVISI;
SetEntityRenderColor(disguiseWeapon , color[0], color[1], color[2], color[3]);
}
else
{
SetEntityRenderMode(disguiseWeapon , RENDER_TRANSCOLOR);
new color[4] = NORMAL;
SetEntityRenderColor(disguiseWeapon , color[0], color[1], color[2], color[3]);
}
}
}
}