You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.9 KiB
61 lines
2.9 KiB
#include <sourcemod>
|
|
|
|
char g_KillfeedChatPrefix[16] = "[FSB.Message]";
|
|
char g_KillfeedTableName[32] = "user_killfeed";
|
|
|
|
char g_SQL_QUERY_ADDKILL[512] = "INSERT INTO `%s` (`attacker_id`, `victim_id`, `assister_id`, `utime`, `weapon_name`, `weapon_id`, `weapon_classname`, `weapon_index`, `custom_kill`, `crit_type`, `server_id`) VALUES ('%d', '%d', '%d', '%d', '%s', '%d', '%s', '%d', '%d', '%d', '%s')";
|
|
|
|
Handle g_hKillfeedDatabase = INVALID_HANDLE;
|
|
char g_kf_server_id[32] = "";
|
|
|
|
stock KillfeedSetup(){
|
|
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
|
|
}
|
|
|
|
stock killfeedSetServerId(const char[] server_id, int size) {
|
|
strcopy(g_kf_server_id, size, server_id);
|
|
PrintToServer("%s server id is setted: %s", g_KillfeedChatPrefix, g_kf_server_id)
|
|
}
|
|
|
|
public CallBack_AddKill(Handle:owner, Handle:hndl, const String:error[], any:data) {
|
|
if (hndl == INVALID_HANDLE) {
|
|
LogError("%s Query failed! %s", g_KillfeedChatPrefix, error);
|
|
return;
|
|
}
|
|
}
|
|
|
|
stock void AddKill(int victim_id, int attacked_id, int assister_id,
|
|
const String:weapon_name[], int weapon_id, const String:weapon_classname[],
|
|
int weapon_index, int custom_kill, int crit_type) {
|
|
char Query[512];
|
|
Format(Query, sizeof(Query), g_SQL_QUERY_ADDKILL, g_KillfeedTableName,
|
|
attacked_id, victim_id, assister_id,
|
|
GetTime(), weapon_name, weapon_id, weapon_classname, weapon_index,
|
|
custom_kill, crit_type, g_kf_server_id);
|
|
SQL_TQuery(g_hKillfeedDatabase, CallBack_AddKill, Query, 0);
|
|
}
|
|
|
|
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast) {
|
|
//user data
|
|
int victim_id = GetEventInt(event, "userid"); //user ID who died
|
|
if (victim_id > 0) victim_id = GetSteamAccountID(GetClientOfUserId(victim_id), true);
|
|
|
|
int attacker_id = GetEventInt(event, "attacker"); //user ID who killed
|
|
if (attacker_id > 0) attacker_id = GetSteamAccountID(GetClientOfUserId(attacker_id), true);
|
|
|
|
int assister_id = GetEventInt(event, "assister"); //user ID of assister
|
|
if (assister_id > 0) assister_id = GetSteamAccountID(GetClientOfUserId(assister_id), true);
|
|
//weapon data
|
|
char weapon_name[64];
|
|
GetEventString(event, "weapon", weapon_name, sizeof(weapon_name)); //weapon name killer used
|
|
int weapon_id = GetEventInt(event, "weaponid"); //ID of weapon killed used
|
|
char weapon_classname[64];
|
|
GetEventString(event, "weapon_logclassname", weapon_classname, sizeof(weapon_classname)); //weapon name that should be printed on the log
|
|
int weapon_index = GetEventInt(event, "weapon_def_index"); //item def index of weapon killer used
|
|
//death data
|
|
int custom_kill = GetEventInt(event, "customkill");//type of custom kill
|
|
int crit_type = GetEventInt(event, "crit_type");//Crit type of kill. (0: None, 1: Mini, 2: Full)
|
|
|
|
AddKill(victim_id, attacker_id, assister_id, weapon_name, weapon_id, weapon_classname, weapon_index, custom_kill, crit_type);
|
|
return Plugin_Continue;
|
|
}
|