I have the same problem on 1.9 and 1.8 SM.
Problem:
On shoot temmate, plugn blaming:
Code:
L 04/15/2018 - 00:15:48: [SM] Exception reported: Instruction contained invalid parameter
L 04/15/2018 - 00:15:48: [SM] Blaming: teamkill.smx
L 04/15/2018 - 00:15:48: [SM] Call stack trace:
L 04/15/2018 - 00:15:48: [SM] [1] Line 64, teamkill.sp::OnTakeDamage
Code:
PHP Code:
#include <maincore>
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_NAME "Team kill"
#define PLUGIN_VERSION "v1.0"
#define PLUGIN_DESCRIPTION "Controling team killing"
#define DEBUG 1
public Plugin myinfo =
{
name = PLUGIN_NAME,
author = "Nerus",
description = PLUGIN_DESCRIPTION,
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/"
};
enum PluginErrors
{
SDKHookError = 1
}
public void OnClientPostAdminCheck(int client)
{
if(!IsValidClient(client))
{
#if DEBUG
PrintToServer("Client: [%d] is invalid", client);
#endif
return;
}
if(!SDKHookEx(client, SDKHook_OnTakeDamageAlive, OnTakeDamage))
ThrowError("Can't hook client: [%d]%N 'On Take Damage'.", client, client);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom)
{
if(IsValidPlayer(victim, false) && IsValidPlayer(attacker, false))
{
if(IsSamePlayer(victim, attacker))
return Plugin_Continue;
else
{
//char WeaponCallBack[32];
//GetEdictClassname(inflictor, WeaponCallBack, sizeof(WeaponCallBack));
//if(StrEqual(WeaponCallBack, "inferno", false) || StrEqual(WeaponCallBack, "hegrenade_projectile", false))
// return Plugin_Continue;
}
if(IsTeammate(victim, attacker))
return Plugin_Handled;
}
// Plugin_Continue Continue with the original action
// Plugin_Changed Inputs or outputs have been overridden with new values
// Plugin_Handled Handle the action at the end (don't call it)
// Plugin_Stop Immediately stop the hook chain and handle the original
return Plugin_Continue; // <-- this is 64 line nr.
}
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <multicolors>
#pragma semicolon 1
//////////////////
// PLAYER
stock int GetClientFromEvent(Handle event)
{
return GetClientOfUserId(GetEventInt(event, "userid"));
}
stock int GetAttackerFromEvent(Handle event)
{
return GetClientOfUserId(GetEventInt(event, "attacker"));
}
stock bool IsClient(int client)
{
return (client > 0 && client < MaxClients+1);
}
stock bool IsValidClient(int client)
{
return (IsClient(client) && IsClientConnected(client) && IsClientInGame(client));
}
stock bool IsValidPlayer(int client, bool only_human)
{
if(only_human)
return (IsValidClient(client) && !IsClientSourceTV(client) && !IsFakeClient(client));
else
return (IsValidClient(client) && !IsClientSourceTV(client));
}
stock bool IsDeadPlayer(int client, bool only_human = false)
{
return (IsValidPlayer(client, only_human) && !IsPlayerAlive(client));
}
stock bool IsAlivePlayer(int client, bool only_human)
{
return (IsValidPlayer(client, only_human) && IsPlayerAlive(client));
}
stock bool IsBot(int client)
{
return (IsValidPlayer(client, false) && IsFakeClient(client));
}
stock bool IsSourceTV(int client)
{
return (IsValidClient(client) && IsClientSourceTV(client));
}
stock bool IsSamePlayer(int client, int other)
{
return (client == other);
}
stock bool IsPlayerAlone(int client)
{
return ( IsAlivePlayer(client, false) && (GetPlayersCountFromTeam(GetClientTeam(client), ONLY_ALIVES, !ONLY_HUMMANS) < 2) );
}
stock bool IsVip(int client)
{
return (IsValidPlayer(client, true) && GetUserAdmin(client) != INVALID_ADMIN_ID);
}
stock bool IsAdmin(int client)
{
return (IsValidPlayer(client, true) && GetAdminFlag(GetUserAdmin(client), Admin_Generic));
}
//////////////////
// Team
stock bool IsTeammate(int client, int second)
{
return (GetClientTeam(client) == GetClientTeam(second));
}