Maybe?
#1

Do you guys think this would be insanely lagg as I do to use it on a 100 players server?

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) {
    for(new i; i < sizeof(item_Info); i++)
        if(item_Info[i][i_Object] == weaponid)
        {
            new query[180],
                ammo = GetPlayerAmmo(playerid);
            if(!ammo)
            {
                format(query, sizeof(query), "REMOVE FROM `inventory` WHERE `itemid` = '%d' AND `uid` = '%d'",
                    i, p_PlayerINFO[playerid][p_ID]);
                mysql_query(g_mysqlDB, query);
            } else {
                format(query, sizeof(query), "UPDATE `inventory` SET `amount` = '%d' WHERE `itemid` = '%d' AND `uid` = '%d'",
                    ammo, i, p_PlayerINFO[playerid][p_ID]
                );
                inline Inv_WeaponAffected() {
                    if(!cache_num_rows()) {
                        // ban
                        return false;
                    }
                }
                mysql_tquery(g_mysqlDB, query, using inline Inv_WeaponAffected);
            }
           
            return true;
        }
    }
   
    // Ban
   
    return false;
}
pastebin >> https://pastebin.com/SBwwRHMr
Reply
#2

Just save the variable and then save it when the player disconnects OR what not? Why run a query everytime they shoot? If someone has like an M4 / AK, I imagine it wouldn't be so good.
Reply
#3

Maybe make a cooldown if the gun is automatic, and count every 5-10 shots if a tick timer hasn't passed.

So that it'd pick up the first if they haven't shot for 2 seconds, and then have it count the 10 then query it or something.

Depends really on how you are using it, as to whether it would be good, or useful in some respects.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)