AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Events id (https://forums.alliedmods.net/showthread.php?t=308974)

4ever16 07-09-2018 13:12

Events id
 
Event
PHP Code:

new weapon_name[32]
read_data(4weapon_name31)            
            
if(
containi(weapon_name"ak47") != -1InsertWeaponKill(CSW_AK47);
else if(
containi(weapon_name"m4a1") != -1InsertWeaponKill(CSW_M4A1); 

mySQL
PHP Code:

public InsertWeaponKill(wpnindex)
{
    new 
szQuery[3800];
    
    
formatexszQuery3799"INSERT INTO `wipon` (`gun_id`, `kills`) VALUES (%d, 1) ON DUPLICATE KEY UPDATE `kills` = `kills` + 1;"wpnindex);
    
    
log_amx(szQuery)
    
SQL_ThreadQueryg_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(idsteam63);
    
    static 
szQuery[3800];
    
formatexszQuery3799"INSERT INTO `wipon` (`player_id`, `gun_id`, `kills`) VALUES ('%s', '%d', 1', NOW());"steamwpnindexON DUPLICATE KEY UPDATE `kills` = `kills` + 1);
    
    
SQL_ThreadQueryg_hTuple"QuerySetData"szQuery);

    return 
PLUGIN_CONTINUE;



^SmileY 07-09-2018 13:31

Re: Events id
 
You need to cache all kills and deaths etc, and when map end or client_disconnect make the updates;
Also consider to use csx module to get client_kill and other things more easily than compare strings


All times are GMT -4. The time now is 12:42.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.