So I did some research and couldn't find any results. I'm trying to make all players on Red Team spawn with their class's default stock melee weapon except it is invisible to make it appear as if they have fists for melee instead of stuff like a bat or a fireaxe. I've gotten everything to work except for firstperson. In firstperson as Scout, I still have a bat. This is what I got.
PHP Code:
#include <sourcemod>
#include <tf2>
#include <tf2items>
#include <tf2_stocks>
public Plugin:myinfo =
{
name = "[TF2] Fists",
author = "Theon32",
description = "Melee is fists only.",
version = "1.0",
url = "https://forums.alliedmods.net/member.php?u=287995"
}
public OnPluginStart()
{
HookEvent("post_inventory_application", Event_PIA);
}
public Event_PIA(Event event, const char[] name, bool dontBroadcast)
{
int iClient = GetClientOfUserId(event.GetInt("userid"));
if (TF2_GetClientTeam(iClient) == TFTeam_Red)
{
new Handle:hWeapon;
hWeapon = TF2Items_CreateItem(OVERRIDE_ALL|FORCE_GENERATION|PRESERVE_ATTRIBUTES);
switch (TF2_GetPlayerClass(iClient))
{
case TFClass_Scout:
{
TF2Items_SetClassname(hWeapon, "tf_weapon_bat");
TF2Items_SetItemIndex(hWeapon, 0);
}
case TFClass_Soldier:
{
TF2Items_SetClassname(hWeapon, "tf_weapon_shovel");
TF2Items_SetItemIndex(hWeapon, 6);
}
case TFClass_Pyro:
{
TF2Items_SetClassname(hWeapon, "tf_weapon_fireaxe");
TF2Items_SetItemIndex(hWeapon, 2);
}
case TFClass_DemoMan:
{
TF2Items_SetClassname(hWeapon, "tf_weapon_bottle");
TF2Items_SetItemIndex(hWeapon, 1);
}
case TFClass_Heavy:
{
TF2Items_SetClassname(hWeapon, "tf_weapon_fists");
TF2Items_SetItemIndex(hWeapon, 5);
}
case TFClass_Engineer:
{
TF2Items_SetClassname(hWeapon, "tf_weapon_wrench");
TF2Items_SetItemIndex(hWeapon, 7);
}
case TFClass_Medic:
{
TF2Items_SetClassname(hWeapon, "tf_weapon_bonesaw");
TF2Items_SetItemIndex(hWeapon, 8);
}
case TFClass_Sniper:
{
TF2Items_SetClassname(hWeapon, "tf_weapon_club");
TF2Items_SetItemIndex(hWeapon, 3);
}
case TFClass_Spy:
{
TF2Items_SetClassname(hWeapon, "tf_weapon_knife");
TF2Items_SetItemIndex(hWeapon, 4);
}
}
TF2Items_SetLevel(hWeapon, 1);
TF2Items_SetQuality(hWeapon, 10);
new String:att[] = "692 ; 1"
new String:atts[32][32];
new count = ExplodeString(att, " ; ", atts, 32, 32);
TF2Items_SetNumAttributes(hWeapon, count/2);
new i2 = 0;
for (new i = 0; i < count; i+=2)
{
TF2Items_SetAttribute(hWeapon, i2, StringToInt(atts[i]), StringToFloat(atts[i+1]));
i2++;
}
if (hWeapon == INVALID_HANDLE)
return -1;
new entity = TF2Items_GiveNamedItem(iClient, hWeapon);
CloseHandle(hWeapon);
if (IsValidEdict(entity))
{
TF2_RemoveWeaponSlot(iClient, 2);
EquipPlayerWeapon (iClient, entity);
}
CreateTimer(1.0, Timer_Delay, entity);
}
}
public Action:Timer_Delay(Handle:timer, any:entity)
SetEntPropFloat(entity, Prop_Send, "m_flModelScale", 0.0);
Thanks!
-Theon
__________________
I like to try and learn off of other people's work and only like to make forum posts when absolutely necessary.