BryceCanyonCounty / bcc-medical

An all in one player and NPC medic script, formerly Legacy_Medic
GNU General Public License v3.0
3 stars 7 forks source link

People can Called Local doc even when Real Doctor Onduty #18

Open cocomonksky opened 1 month ago

cocomonksky commented 1 month ago

So i Have found an issue about the Local Doc not detected Onduty doctor for Syn Society.

https://discord.com/channels/1021957724440899584/1298372190667800607/1298372190667800607

cocomonksky commented 4 weeks ago

okay now i found a way to solved this.. i just change the line 52 in server.lua to

RegisterNetEvent('bcc-medical:AlertJobs', function()
    local src = source
    local user = VORPcore.getUser(src)
    if not user then return end
    local docs = 0

    if Config.synsociety then
        -- Check if there are any medics on duty
        if CheckPlayer(StaffTable, MedicJobs[1]) or CheckPlayer(StaffTable, MedicJobs[2]) then
            VORPcore.NotifyRightTip(src, _U('doctoractive'), 4000)
            return -- Exit if medics are on duty
        else
            TriggerClientEvent('bcc-medical:CallNpcDoctor', src)
            return
        end
    else
        -- Alternative check without syn_society
        for _, player in ipairs(GetPlayers()) do
            local playerUser = VORPcore.getUser(player)
            local playerChar = playerUser.getUsedCharacter
            if CheckTable(MedicJobs, playerChar.job) then
                docs = docs + 1
            end
        end
    end

    -- NPC call is only triggered if no doctors are found
    if docs < 1 then
        TriggerClientEvent('bcc-medical:CallNpcDoctor', src)
    else
        VORPcore.NotifyRightTip(src, _U('doctoractive2'), 4000)
    end
end)