From bd28f247eac2e803a128ea779218e7ebf8a5437c Mon Sep 17 00:00:00 2001 From: erfan ebrahimi Date: Tue, 9 Mar 2021 16:37:33 +0330 Subject: [PATCH] update player Identifier for multi character server --- BaseFunction.lua | 8 +++ QBusFunction.lua | 11 ++++ esxBaseFunction.lua | 11 ++++ server/admin.lua | 8 +-- server/gangData.lua | 141 ++++++-------------------------------------- server/main.lua | 42 ++----------- server/salary.lua | 9 +-- server/vehicle.lua | 28 ++------- 8 files changed, 63 insertions(+), 195 deletions(-) diff --git a/BaseFunction.lua b/BaseFunction.lua index b4d7105..095c671 100644 --- a/BaseFunction.lua +++ b/BaseFunction.lua @@ -3,6 +3,14 @@ function GetRealPlayerName(playerId) -- Like: return Player.GetName() end +function getPlayerIdentifier(playerId) + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + return v + break + end + -- return identifier of player +end + function GetOOCPlayerName(playerId) return GetPlayerName(playerId) end diff --git a/QBusFunction.lua b/QBusFunction.lua index 3eda714..196b822 100644 --- a/QBusFunction.lua +++ b/QBusFunction.lua @@ -7,6 +7,17 @@ Citizen.CreateThread(function() end end) +function getPlayerIdentifier(playerId) + local Player = ESX.Functions.GetPlayer(playerId) + if Player and Player.PlayerData then + return Player.PlayerData.citizenid + else + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + return v + break + end + end +end function GetRealPlayerName(playerId) local Player = ESX.Functions.GetPlayer(playerId) diff --git a/esxBaseFunction.lua b/esxBaseFunction.lua index ceba8fc..21fb1c6 100644 --- a/esxBaseFunction.lua +++ b/esxBaseFunction.lua @@ -7,6 +7,17 @@ Citizen.CreateThread(function() end end) +function getPlayerIdentifier(playerId) + local xPlayer = ESX.GetPlayerFromId(playerId) + if xPlayer then + return xPlayer.identifier + else + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + return v + break + end + end +end function GetRealPlayerName(playerId) local xPlayer = ESX.GetPlayerFromId(playerId) diff --git a/server/admin.lua b/server/admin.lua index b71b97b..54e0f68 100644 --- a/server/admin.lua +++ b/server/admin.lua @@ -152,13 +152,7 @@ RegisterServerEvent('Erfan:gang:addPlayerToGang') AddEventHandler('Erfan:gang:addPlayerToGang', function(gangId , playerId , gradeId) local _Source = source if IsPlayerAceAllowed(_Source, "gang.admin") then - local identifier = nil - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(playerId) if identifier ~= nil then executeOnDB("DELETE FROM `gangs_member` WHERE `playerIdentifiers` = @playerIdentifiers", { ['@playerIdentifiers'] = identifier diff --git a/server/gangData.lua b/server/gangData.lua index 3607e81..8d668fa 100644 --- a/server/gangData.lua +++ b/server/gangData.lua @@ -4,13 +4,7 @@ RegisterServerEvent('Erfan:gang:getActiveGang') AddEventHandler('Erfan:gang:getActiveGang', function() local _Source = source local gangs = selectFromDB("SELECT * , DATE_FORMAT(expireTime, '%Y/%m/%d') as expireTimeFormat FROM gangs where expireTime > NOW()", {}) - - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier then TriggerClientEvent('Erfan:gang:setGangData',_Source,gangs , gang[1].gangId , gang[1].grade ) @@ -53,12 +47,7 @@ end) RegisterCommand("sethook", function(src, args, rawCommand) if rawCommand:sub(9) then local _Source = src - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then executeOnDB('UPDATE `gangs` SET `discordHook` = @discordHook WHERE id = @gangId', { @@ -80,12 +69,7 @@ RegisterServerEvent('Erfan:gang:depositMoney') AddEventHandler('Erfan:gang:depositMoney', function(amount) local _Source = source amount = tonumber(amount) - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then local setMoney = setPlayerMoney(_Source,amount,'remove') @@ -115,12 +99,7 @@ RegisterServerEvent('Erfan:gang:withdrawMoney') AddEventHandler('Erfan:gang:withdrawMoney', function(amount) local _Source = source amount = tonumber(amount) - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then local gangData = selectFromDB("SELECT * FROM gangs WHERE id = @id", { ['@id'] = gang[1].gangId }) @@ -156,12 +135,7 @@ end) RegisterServerEvent('Erfan:gang:getRanksOfmyGang') AddEventHandler('Erfan:gang:getRanksOfmyGang', function() local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then local grades = selectFromDB("SELECT * FROM gangs_grade WHERE gangId = @gangId", { ['@gangId'] = gang[1].gangId }) @@ -177,12 +151,7 @@ RegisterServerEvent('Erfan:gang:creatNewGrade') AddEventHandler('Erfan:gang:creatNewGrade', function(name) local _Source = source amount = tonumber(amount) - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then local maxGrade = selectFromDB("SELECT MAX(grade) + 1 as garde FROM `gangs_grade` WHERE `gangId` = @gangId", { ['@gangId'] = gang[1].gangId }) @@ -210,12 +179,7 @@ RegisterServerEvent('Erfan:gang:updateGradeData') AddEventHandler('Erfan:gang:updateGradeData', function(gradeId , variabel , value) local _Source = source amount = tonumber(amount) - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then executeOnDB('UPDATE `gangs_grade` set `'..variabel..'` = @value where gradeId = @gradeId and `gangId` = @gangId', { @@ -236,12 +200,7 @@ end) RegisterServerEvent('Erfan:gang:getMembersOfmyGang') AddEventHandler('Erfan:gang:getMembersOfmyGang', function() local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then local members = selectFromDB("SELECT * FROM gangs_member WHERE gangId = @gangId", { ['@gangId'] = gang[1].gangId }) @@ -258,27 +217,12 @@ end) RegisterServerEvent('Erfan:gang:addNewMember') AddEventHandler('Erfan:gang:addNewMember', function(gradeId , playerId) -print(gradeId) -print(playerId) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then local identifier = nil - print(gradeId) - print(playerId) - print(GetPlayerIdentifiers(playerId)) - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + identifier = getPlayerIdentifier(playerId) if identifier ~= nil then executeOnDB("DELETE FROM `gangs_member` WHERE `playerIdentifiers` = @playerIdentifiers", { ['@playerIdentifiers'] = identifier @@ -311,12 +255,7 @@ end) RegisterServerEvent('Erfan:gang:changeGradeMemberFromGang') AddEventHandler('Erfan:gang:changeGradeMemberFromGang', function( playerId , gradeId) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then executeOnDB("UPDATE `gangs_member` set `grade` = @grade where playerIdentifiers = @playerIdentifiers and gangId = @gangId ", { @@ -326,13 +265,7 @@ AddEventHandler('Erfan:gang:changeGradeMemberFromGang', function( playerId , gra } , function(e) if activeGangMember['g_'..gang[1].gangId] then for _key1,gangMemberSRC in ipairs(activeGangMember['g_'..gang[1].gangId]) do - local identifierCheck = nil - for _key2,identi in ipairs(GetPlayerIdentifiers(gangMemberSRC)) do - if string.match(identi, Config.IdentifiersPlayerWith ) then - identifierCheck = identi - break - end - end + local identifierCheck = getPlayerIdentifier(gangMemberSRC) if identifierCheck == playerId then playerId = gangMemberSRC break @@ -351,12 +284,7 @@ end) RegisterServerEvent('Erfan:gang:deleteMemberFromGang') AddEventHandler('Erfan:gang:deleteMemberFromGang', function(playerId) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].grade == 0 then local identifier = playerId @@ -365,13 +293,7 @@ AddEventHandler('Erfan:gang:deleteMemberFromGang', function(playerId) } , function(e) if activeGangMember['g_'..gang[1].gangId] then for _key1,gangMemberSRC in ipairs(activeGangMember['g_'..gang[1].gangId]) do - local identifierCheck = nil - for _key2,identi in ipairs(GetPlayerIdentifiers(gangMemberSRC)) do - if string.match(identi, Config.IdentifiersPlayerWith ) then - identifierCheck = identi - break - end - end + local identifierCheck = getPlayerIdentifier(gangMemberSRC) if identifierCheck == identifier then table.remove( activeGangMember['g_'..gang[1].gangId] , _key1 ) playerId = gangMemberSRC @@ -394,12 +316,7 @@ end) RegisterServerEvent('Erfan:gang:wearGang') AddEventHandler('Erfan:gang:wearGang', function() local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT * FROM gangs_member WHERE playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier then local grade = selectFromDB("SELECT * FROM gangs_grade WHERE gangId = @gangId and grade = @grade ", { ['@gangId'] = gang[1].gangId , ['@grade'] = gang[1].grade }) @@ -416,12 +333,7 @@ end) RegisterServerEvent('Erfan:gang:armory_deposit') AddEventHandler('Erfan:gang:armory_deposit', function() local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , gg.accessArmory FROM gangs_member gm Left Join gangs_grade gg on (gg.gangId = gm.gangId and gg.grade = gm.grade ) WHERE gm.playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].accessArmory then TriggerClientEvent('Erfan:gang:armory_deposit_open',_Source, OpenPlayerInventory(_Source) ) @@ -433,12 +345,7 @@ end) RegisterServerEvent('Erfan:gang:armory_withdraw') AddEventHandler('Erfan:gang:armory_withdraw', function() local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , gg.accessArmory , g.inventory FROM gangs_member gm Left Join gangs_grade gg on (gg.gangId = gm.gangId and gg.grade = gm.grade ) Left Join gangs g on (g.id = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].accessArmory then TriggerClientEvent('Erfan:gang:armory_withdraw_open',_Source, json.decode(gang[1].inventory) ) @@ -450,12 +357,7 @@ end) RegisterServerEvent('Erfan:gang:armory_depositing') AddEventHandler('Erfan:gang:armory_depositing', function(item , amount) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , gg.accessArmory , gm.gangId, g.inventory, g.discordHook FROM gangs_member gm Left Join gangs_grade gg on (gg.gangId = gm.gangId and gg.grade = gm.grade ) Left Join gangs g on (g.id = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].accessArmory then local IsItemGet = PlayerInventoryGetItem(_Source, item.itemType, item.value, amount) @@ -495,12 +397,7 @@ end) RegisterServerEvent('Erfan:gang:armory_withdrawing') AddEventHandler('Erfan:gang:armory_withdrawing', function(item , amount) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , gg.accessArmory , gm.gangId, g.inventory, g.discordHook FROM gangs_member gm Left Join gangs_grade gg on (gg.gangId = gm.gangId and gg.grade = gm.grade ) Left Join gangs g on (g.id = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].accessArmory then local gangInventory = json.decode(gang[1].inventory) diff --git a/server/main.lua b/server/main.lua index 0e73333..b92417f 100644 --- a/server/main.lua +++ b/server/main.lua @@ -7,12 +7,7 @@ end) RegisterNetEvent('Erfan:gang:handcuff') AddEventHandler('Erfan:gang:handcuff', function(target) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , g.canCuff FROM gangs_member gm Left Join gangs g on (g.id = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers and g.expireTime > NOW()", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].canCuff then TriggerClientEvent('Erfan:gang:handcuff', target) @@ -24,12 +19,7 @@ end) RegisterNetEvent('Erfan:gang:drag') AddEventHandler('Erfan:gang:drag', function(target) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , g.canMove FROM gangs_member gm Left Join gangs g on (g.id = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers and g.expireTime > NOW()", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].canMove then TriggerClientEvent('Erfan:gang:drag', target , _Source) @@ -41,12 +31,7 @@ end) RegisterNetEvent('Erfan:gang:putInVehicle') AddEventHandler('Erfan:gang:putInVehicle', function(target) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , g.canMove FROM gangs_member gm Left Join gangs g on (g.id = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers and g.expireTime > NOW()", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].canMove then TriggerClientEvent('Erfan:gang:putInVehicle', target) @@ -58,12 +43,7 @@ end) RegisterNetEvent('Erfan:gang:OutVehicle') AddEventHandler('Erfan:gang:OutVehicle', function(target) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , g.canMove FROM gangs_member gm Left Join gangs g on (g.id = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers and g.expireTime > NOW()", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].canMove then TriggerClientEvent('Erfan:gang:OutVehicle',target) @@ -79,12 +59,7 @@ end) RegisterServerEvent('Erfan:gang:searchBody') AddEventHandler('Erfan:gang:searchBody', function(target) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , g.canSearch FROM gangs_member gm Left Join gangs g on (g.id = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers and g.expireTime > NOW()", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].canSearch then TriggerClientEvent('Erfan:gang:sendNotficationFromPlayer',target,_Source,'', '' , _U('you_have_been_robberd') , 'CHAR_SOCIAL_CLUB' , 2 ) @@ -101,12 +76,7 @@ end) RegisterServerEvent('Erfan:gang:searchBodyGetItem') AddEventHandler('Erfan:gang:searchBodyGetItem', function(item , amount,TargetId) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , g.canSearch FROM gangs_member gm Left Join gangs g on (g.id = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers and g.expireTime > NOW()", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].canSearch then local IsItemGet = PlayerInventoryGetItem(TargetId, item.itemType, item.value, amount) diff --git a/server/salary.lua b/server/salary.lua index 7528b26..c2f9a3e 100644 --- a/server/salary.lua +++ b/server/salary.lua @@ -1,13 +1,10 @@ function payCheck() local members = {} - print(json.encode(activeGangMember)) for gangId,memmbersInGang in pairs(activeGangMember) do for _k,memmberId in pairs(memmbersInGang) do - for k,v in pairs(GetPlayerIdentifiers(memmberId)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - members[v] = memmberId - break - end + local memberIdnti = getPlayerIdentifier(memmberId) + if ( memberIdnti ~= nil ) then + members[memberIdnti] = memmberId end end end diff --git a/server/vehicle.lua b/server/vehicle.lua index 0fcae6a..4e99ee3 100644 --- a/server/vehicle.lua +++ b/server/vehicle.lua @@ -3,12 +3,7 @@ local vehicleImpoundSpawn = {} RegisterServerEvent('Erfan:gang:openImpoundMenu') AddEventHandler('Erfan:gang:openImpoundMenu', function(typeVehicle,vehicleProperties) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , gg.accessVehicle , gm.gangId FROM gangs_member gm Left Join gangs_grade gg on (gg.gangId = gm.gangId and gg.grade = gm.grade ) WHERE gm.playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].accessVehicle then local canInsertToGarage = false @@ -62,12 +57,7 @@ end RegisterServerEvent('Erfan:gang:addVehicle') AddEventHandler('Erfan:gang:addVehicle', function(vehicleProperties ) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , gg.accessVehicle , gm.gangId FROM gangs_member gm Left Join gangs_grade gg on (gg.gangId = gm.gangId and gg.grade = gm.grade ) WHERE gm.playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].accessVehicle then local isReapeted = true @@ -143,12 +133,7 @@ end) RegisterServerEvent('Erfan:gang:openGarage') AddEventHandler('Erfan:gang:openGarage', function(typeVehicle , vehicleProperties) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , gg.accessVehicle , gm.gangId FROM gangs_member gm Left Join gangs_grade gg on (gg.gangId = gm.gangId and gg.grade = gm.grade ) WHERE gm.playerIdentifiers = @playerIdentifiers", { ['@playerIdentifiers'] = identifier }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].accessVehicle then local canInsertToGarage = false @@ -170,12 +155,7 @@ end) RegisterServerEvent('Erfan:gang:isOwnVehicle') AddEventHandler('Erfan:gang:isOwnVehicle', function(plate,cb) local _Source = source - for k,v in ipairs(GetPlayerIdentifiers(_Source)) do - if string.match(v, Config.IdentifiersPlayerWith ) then - identifier = v - break - end - end + local identifier = getPlayerIdentifier(_Source) local gang = selectFromDB("SELECT gm.playerIdentifiers , gm.gangId, gv.plate FROM gangs_member gm Left Join gangs_vehicle gv on (gv.gangId = gm.gangId ) WHERE gm.playerIdentifiers = @playerIdentifiers and gv.plate = @plate ", { ['@playerIdentifiers'] = identifier , ['@plate'] = plate }) if gang ~= nil and gang[1] ~= nil and gang[1].playerIdentifiers == identifier and gang[1].plate == plate then TriggerClientEvent('Erfan:gang:isOwnGangVehicle', _Source , true )