Permalink
Browse files

Changed method to remove weapons

  • Loading branch information...
Bara committed Dec 7, 2017
1 parent 4663e61 commit 95343b5872d95467fd8608b21815c027927a8965
@@ -331,7 +331,7 @@ stock bool tHasFlags(int client, AdminFlag flags[16])
return false;
}
stock bool TTT_RemoveWeaponByClassname(int client, const char[] classname)
stock bool TTT_RemoveWeaponByClassname(int client, const char[] classname, int slot)
{
for(int offset = 0; offset < 128; offset += 4)
{
@@ -344,43 +344,66 @@ stock bool TTT_RemoveWeaponByClassname(int client, const char[] classname)
if (StrEqual(sClass, classname, false))
{
return TTT_SafeRemoveWeapon(client, weapon);
return TTT_SafeRemoveWeapon(client, weapon, slot);
}
}
}
return false;
}
stock bool TTT_SafeRemoveWeapon(int iClient, int iWeapon)
stock bool TTT_SafeRemoveWeapon(int client, int weapon, int slot)
{
if (!IsValidEntity(iWeapon) || !IsValidEdict(iWeapon))
return false;
if (!HasEntProp(iWeapon, Prop_Send, "m_hOwnerEntity"))
int iDefIndex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
if (iDefIndex < 0 || iDefIndex > 700)
{
return false;
int iOwnerEntity = GetEntPropEnt(iWeapon, Prop_Send, "m_hOwnerEntity");
if (iOwnerEntity != iClient)
SetEntPropEnt(iWeapon, Prop_Send, "m_hOwnerEntity", iClient);
CS_DropWeapon(iClient, iWeapon, false);
if (HasEntProp(iWeapon, Prop_Send, "m_hWeaponWorldModel"))
}
if (HasEntProp(weapon, Prop_Send, "m_bInitialized"))
{
int iWorldModel = GetEntPropEnt(iWeapon, Prop_Send, "m_hWeaponWorldModel");
if (IsValidEdict(iWorldModel) && IsValidEntity(iWorldModel))
if (!AcceptEntityInput(iWorldModel, "Kill"))
return false;
if (GetEntProp(weapon, Prop_Send, "m_bInitialized") == 0)
{
return false;
}
}
if (!AcceptEntityInput(iWeapon, "Kill"))
if (HasEntProp(weapon, Prop_Send, "m_bStartedArming"))
{
if (GetEntSendPropOffs(weapon, "m_bStartedArming") > -1)
{
return false;
}
}
if (GetPlayerWeaponSlot(client, slot) != weapon)
{
return false;
}
if (!RemovePlayerItem(client, weapon))
{
return false;
}
int iWorldModel = GetEntPropEnt(weapon, Prop_Send, "m_hWeaponWorldModel");
if (IsValidEdict(iWorldModel) && IsValidEntity(iWorldModel))
{
if (!AcceptEntityInput(iWorldModel, "Kill"))
{
return false;
}
}
if (weapon == GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"))
{
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", -1);
}
AcceptEntityInput(weapon, "Kill");
return true;
}
@@ -1102,7 +1102,7 @@ stock void TeamInitialize(int client)
}
else if (g_cPrimaryWeaponUpdate.IntValue == 2)
{
TTT_SafeRemoveWeapon(client, iWeapon);
TTT_SafeRemoveWeapon(client, iWeapon, CS_SLOT_PRIMARY);
GivePlayerItem(client, g_sDefaultPrimary);
}
}
@@ -1136,7 +1136,7 @@ stock void TeamInitialize(int client)
}
else if (g_cSecondaryWeaponUpdate.IntValue == 2)
{
TTT_SafeRemoveWeapon(client, iWeapon);
TTT_SafeRemoveWeapon(client, iWeapon, CS_SLOT_SECONDARY);
GivePlayerItem(client, g_sDefaultSecondary);
}
}
@@ -1179,7 +1179,7 @@ stock void TeamInitialize(int client)
}
else if (g_cSecondaryWeaponUpdate.IntValue == 2)
{
TTT_SafeRemoveWeapon(client, iWeapon);
TTT_SafeRemoveWeapon(client, iWeapon, CS_SLOT_SECONDARY);
GivePlayerItem(client, g_sDefaultSecondary);
}
}
@@ -1218,7 +1218,7 @@ stock void TeamInitialize(int client)
if (StrContains(sBuffer, "knife", false) != -1 || StrContains(sBuffer, "bayonet", false) != -1)
{
TTT_SafeRemoveWeapon(client, iEnt);
TTT_SafeRemoveWeapon(client, iEnt, CS_SLOT_KNIFE);
}
}
}
@@ -1238,7 +1238,7 @@ stock void TeamInitialize(int client)
}
else if (g_cSecondaryWeaponUpdate.IntValue == 2)
{
TTT_SafeRemoveWeapon(client, iWeapon);
TTT_SafeRemoveWeapon(client, iWeapon, CS_SLOT_SECONDARY);
GivePlayerItem(client, g_sDefaultSecondary);
}
}
@@ -3780,7 +3780,7 @@ stock void StripAllWeapons(int client)
{
while ((iEnt = GetPlayerWeaponSlot(client, i)) != -1)
{
TTT_SafeRemoveWeapon(client, iEnt);
TTT_SafeRemoveWeapon(client, iEnt, i);
}
}
}
@@ -282,7 +282,7 @@ stock bool RemoveC4(int client)
{
if (!g_bHasC4[client] && !g_bHasJihad[client])
{
return TTT_RemoveWeaponByClassname(client, "weapon_c4");
return TTT_RemoveWeaponByClassname(client, "weapon_c4", CS_SLOT_C4);
}
return false;
@@ -100,7 +100,7 @@ public Action TTT_OnItemPurchased(int client, const char[] itemshort, bool count
return Plugin_Stop;
}
TTT_RemoveWeaponByClassname(client, "weapon_tagrenade");
TTT_RemoveWeaponByClassname(client, "weapon_tagrenade", CS_SLOT_GRENADE);
GivePlayerItem(client, "weapon_tagrenade");
}
@@ -177,7 +177,7 @@ public Action TTT_OnItemPurchased(int client, const char[] itemshort, bool count
g_bHasKnockout[client] = true;
TTT_RemoveWeaponByClassname(client, "weapon_taser");
TTT_RemoveWeaponByClassname(client, "weapon_taser", CS_SLOT_KNIFE);
GivePlayerItem(client, "weapon_taser");
}
@@ -317,7 +317,7 @@ stock void DropWeapons(int client)
if ((StrContains(sClass, "knife", false) != -1) || (StrContains(sClass, "bayonet", false) != -1))
{
TTT_SafeRemoveWeapon(client, weapon);
TTT_SafeRemoveWeapon(client, weapon, CS_SLOT_KNIFE);
}
else
{
@@ -137,7 +137,7 @@ public Action TTT_OnItemPurchased(int client, const char[] itemshort)
int iWeapon = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY);
if (iWeapon != -1)
{
TTT_SafeRemoveWeapon(client, iWeapon);
TTT_SafeRemoveWeapon(client, iWeapon, CS_SLOT_PRIMARY);
}
g_iWeapon[client] = GivePlayerItem(client, "weapon_awp");

0 comments on commit 95343b5

Please sign in to comment.