SA:MP Help with sampev.onBulletSync

alexeilol

Известный
Автор темы
1
0
Версия SA-MP
  1. 0.3.7 (R1)
Hello, I've been having a issue with one of my scripts. The script is fundamentally ensables chams for a player once they get shot if you're looking at the player who shot them, but I've had a problem with it not working when the player is sniping them, moments is just doesn't work, yet other times it works without issue.
I'm worrying if anyone more knowledgeable can spot the issue in the function and if there is any way to fix it. Thank you in advance :)

OnBulletSync:
function sampev.onBulletSync(id, data)
    if spectating_player_id == nil or not is_spectating then
        return
    end
    local targetId = nil
    if data.targetType == 1 then
        targetId = data.targetId
    end
    if ch_victim_chams.v then
        if spectating_player_id == id then
            if targetId then
                if ch_hitmarker_sound.v then
                    playsound(SOUND_DIR .. hitmarker_sound_file)
                end
                for k, I in ipairs(getAllChars()) do
                    local result, playerId = sampGetPlayerIdByCharHandle(i)
                    if result and playerId == targetId then
                        VictimChams[i] = {time = os.clock() + victim_chams_duration.v }
                        break
                    end
                end
            end
        end
    end
    if ch_damage_tracker.v then
        addDamageEntry(id, targetId, data.weaponId)
    end
end