#include <sourcemod>
#include <freak_fortress_2>
#include <tf2_stocks>
#include <tf2items>
public OnPluginStart()
{
HookEvent("player_spawn", event_player_spawn, EventHookMode_Pre);
}
public Action:event_player_spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client=GetClientOfUserId(GetEventInt(event, "userid"));
CreateTimer(0.15, CheckItems, client);
return Plugin_Continue;
}
public Action:CheckItems(Handle:timer, any:client)
{
if(!IsValidClient(client) || !IsPlayerAlive(client) || FF2_GetBossIndex(client)!=-1)
{
return Plugin_Continue;
}
new weapon=GetPlayerWeaponSlot(client, TFWeaponSlot_Primary);
new index=-1;
if(weapon && IsValidEdict(weapon))
{
index=GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
switch(index)
{
case 230: //The Sydney Sleeper
{
TF2_RemoveWeaponSlot(client, TFWeaponSlot_Primary);
SpawnWeapon(client, "tf_weapon_sniperrifle", 14, 1, 0, ""); //Sniper Rifle
}
}
}
weapon=GetPlayerWeaponSlot(client, TFWeaponSlot_Melee);
if(weapon && IsValidEdict(weapon))
{
index=GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
switch(index)
{
case 649: //Spy-cicle
{
TF2_RemoveWeaponSlot(client, TFWeaponSlot_Melee);
weapon=SpawnWeapon(client, "tf_weapon_knife", 4, 1, 0, ""); //Knife
}
}
}
weapon=GetPlayerWeaponSlot(client, 4);
if(weapon && IsValidEdict(weapon))
{
index=GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
switch(index)
{
case 60: //Cloak and Dagger
{
TF2_RemoveWeaponSlot(client, 4);
SpawnWeapon(client, "tf_weapon_invis", 30, 1, 0, ""); //Watch
}
}
}
return Plugin_Continue;
}
stock bool:IsValidClient(client, bool:replaycheck=true)
{
if(client<=0 || client>MaxClients)
{
return false;
}
if(!IsClientInGame(client))
{
return false;
}
if(GetEntProp(client, Prop_Send, "m_bIsCoaching"))
{
return false;
}
if(replaycheck)
{
if(IsClientSourceTV(client) || IsClientReplay(client))
{
return false;
}
}
return true;
}
stock SpawnWeapon(client, String:name[], index, level, qual, String:att[])
{
new Handle:hWeapon=TF2Items_CreateItem(OVERRIDE_ALL|FORCE_GENERATION);
if(hWeapon==INVALID_HANDLE)
{
return -1;
}
TF2Items_SetClassname(hWeapon, name);
TF2Items_SetItemIndex(hWeapon, index);
TF2Items_SetLevel(hWeapon, level);
TF2Items_SetQuality(hWeapon, qual);
new String:atts[32][32];
new count=ExplodeString(att, ";", atts, 32, 32);
if(count % 2)
{
--count;
}
if(count>0)
{
TF2Items_SetNumAttributes(hWeapon, count/2);
new i2;
for(new i; i<count; i+=2)
{
new attrib=StringToInt(atts[i]);
if(!attrib)
{
LogError("Bad weapon attribute passed: %s ; %s", atts[i], atts[i+1]);
CloseHandle(hWeapon);
return -1;
}
TF2Items_SetAttribute(hWeapon, i2, attrib, StringToFloat(atts[i+1]));
i2++;
}
}
else
{
TF2Items_SetNumAttributes(hWeapon, 0);
}
new entity=TF2Items_GiveNamedItem(client, hWeapon);
CloseHandle(hWeapon);
EquipPlayerWeapon(client, entity);
return entity;
}
Comments
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎