Event
PHP Code:
new weapon_name[32]
read_data(4, weapon_name, 31)
if(containi(weapon_name, "ak47") != -1) InsertWeaponKill(CSW_AK47);
else if(containi(weapon_name, "m4a1") != -1) InsertWeaponKill(CSW_M4A1);
mySQL
PHP Code:
public InsertWeaponKill(wpnindex)
{
new szQuery[3800];
formatex( szQuery, 3799, "INSERT INTO `wipon` (`gun_id`, `kills`) VALUES (%d, 1) ON DUPLICATE KEY UPDATE `kills` = `kills` + 1;", wpnindex);
log_amx(szQuery)
SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
}
If someone kills someone with AK47 then value goes up +1.
But i would like to find the killers steam id and write it to database. Steam id + gun id + kills.
Everything works fine with the old code but it counts total amount of kills by that specific gun. I need that it counts by specific steam id.
Is it possible?
I was thinking something like this. I know its not correct coded but its just an idea.
PHP Code:
public InsertWeaponKill(wpnindex)
{
new steam[64];
get_user_authid(id, steam, 63);
static szQuery[3800];
formatex( szQuery, 3799, "INSERT INTO `wipon` (`player_id`, `gun_id`, `kills`) VALUES ('%s', '%d', 1', NOW());", steam, wpnindex, ON DUPLICATE KEY UPDATE `kills` = `kills` + 1);
SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
return PLUGIN_CONTINUE;
}