N3MTV / gcphone

Téléphone pour FiveM
104 stars 228 forks source link

Problem with New ESX- #327

Open DestinyDragon49 opened 4 years ago

DestinyDragon49 commented 4 years ago

When i call, the console show this: [gcphone] An error happens on MySQL for query "INSERT INTO phone_calls (owner, num,incoming, accepts) VALUES(@owner, 'police', 1, false)": ER_BAD_NULL_ERROR: Column 'owner' cannot be null

GWhite01 commented 4 years ago

I tried this and it worked for me: in server.lua, add this at the beginning

local ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) 
    ESX = obj 
end)

Replace

function getPlayerID(source)
    local identifiers = GetPlayerIdentifiers(source)
    local player = getIdentifiant(identifiers)
    return player
end

by

function getPlayerID(source)
    local xplayer = ESX.GetPlayerFromId(source)
    local player = xplayer.identifier
    return player
end

Then replace

function getSourceFromIdentifier(identifier, cb)
    TriggerEvent("esx:getPlayers", function(users)
        for k , user in pairs(users) do
            if (user.getIdentifier ~= nil and user.getIdentifier() == identifier) or (user.identifier == identifier) then
                cb(k)
                return
            end
        end
    end)
    cb(nil)
end

by

function getSourceFromIdentifier(identifier, cb)
    local users = ESX.GetPlayers()
    for k , user in pairs(users) do
        local xplayer = ESX.GetPlayerFromId(user)
        if (xplayer.getIdentifier ~= nil and xplayer.getIdentifier() == identifier) or (xplayer.identifier == identifier) then
            cb(k)
            return
        end
    end
    --cb(nil)
end

and if the phone numbers aren’t given replace:

es:playerLoaded

by

esx:playerLoaded

You'll still have an error on the console but it works

DestinyDragon49 commented 4 years ago

Thank you, it worked but i change this:

function getPlayerID(source)
    local xplayer = ESX.GetPlayerFromId(source)
    local player = xplayer.identifier
    return player
end

to this

function getPlayerID(source)
    local xPlayer = ESX.GetPlayerFromId(source)
    local player = xPlayer.getIdentifier()
    return player
end 

btw the console show this: SCRIPT ERROR: @gcphone/server/server.lua:82: attempt to index a nil value (local 'xPlayer')

but it does not affect the operation, I think I will leave it like that lol 🤷‍♂️

phpadmin1 commented 4 years ago

It worked but when you got more players inside phone number shuffled . I mean instead of you will received that message other player received? anyone ?

esegovicDev37 commented 4 years ago

Its still not working. Hmm i think we need to rework complete server side

heyhoung commented 4 years ago

same issue for the fixing SCRIPT ERROR: @gcphone/server/server.lua:82: attempt to index a nil value (local 'xPlayer')

andercrack24 commented 4 years ago

ny solution for this problem. Regards. I'm a little bad for English

mwasif02 commented 4 years ago

@Guigui thanks a lot man!

Michaleqxx commented 4 years ago

Thanks! This working

startripshooters commented 4 years ago

It worked but when you got more players inside phone number shuffled . I mean instead of you will received that message other player received? anyone ?

@phpadmin1 same for me, do you have a solution ?

allChuu commented 4 years ago

It worked but when you got more players inside phone number shuffled . I mean instead of you will received that message other player received? anyone ?

@phpadmin1 same for me, do you have a solution ?

https://forum.cfx.re/t/q-a-gcphone-questions-ask-them-here-will-update-main-post-frequently-with-updates/494656/370