forked from Simnation/Main
1 line
13 KiB
Lua
1 line
13 KiB
Lua
![]() |
StartESX=function(a)ESX=exports["es_extended"]:getSharedObject()end;StartQB=function(a)QBCore=exports['qb-core']:GetCoreObject()end;ShowNotification=function(b,c,type)if GetResourceState("qb-core")=="started"then TriggerClientEvent('QBCore:Notify',b,c,type)elseif GetResourceState("es_extended")=="started"then TriggerClientEvent('esx:showNotification',b,c)end end;CreateLoop=function(d,e)Citizen.CreateThread(function()local f=true;_break=function()f=false end;while f do d()Citizen.Wait(e or 5)end end)end;AddItem=function(b,...)if ESX then xPlayer=ESX.GetPlayerFromId(b)xPlayer.addInventoryItem(...)else xPlayer=QBCore.Functions.GetPlayer(b)xPlayer.Functions.AddItem(...)end end;RemoveItem=function(b,...)if ESX then xPlayer=ESX.GetPlayerFromId(b)xPlayer.removeInventoryItem(...)else xPlayer=QBCore.Functions.GetPlayer(b)xPlayer.Functions.RemoveItem(...)end end;GetItem=function(b,...)if ESX then xPlayer=ESX.GetPlayerFromId(b)return xPlayer.getInventoryItem(...)else xPlayer=QBCore.Functions.GetPlayer(b)return xPlayer.Functions.GetItemByName(...)end end;HaveItem=function(b,...)if ESX then return GetItem(b,...).count>0 else return GetItem(b,...).amount>0 end end;HaveItemQuantity=function(b,g,h)if ESX then return GetItem(b,g).count>h else return GetItem(b,g).amount>h end end;AddMoney=function(b,type,...)if ESX then xPlayer=ESX.GetPlayerFromId(b)if type=="cash"then xPlayer.addMoney(...)else xPlayer.addAccountMoney(type,...)end else xPlayer=QBCore.Functions.GetPlayer(b)xPlayer.Functions.AddMoney(type,...)end end;RemoveMoney=function(b,type,...)if ESX then xPlayer=ESX.GetPlayerFromId(b)if type=="cash"then xPlayer.removeMoney(...)else xPlayer.removeAccountMoney(type,...)end else xPlayer=QBCore.Functions.GetPlayer(b)xPlayer.Functions.RemoveMoney(type,...)end end;HaveMoney=function(b,type,i)if ESX then xPlayer=ESX.GetPlayerFromId(b)if type=="cash"then return xPlayer.getMoney(type)>=i else return xPlayer.getAccount(type).money>=i end else xPlayer=QBCore.Functions.GetPlayer(b)return xPlayer.Functions.GetMoney(type)>=i end end;StartMySQL=function()MySQL={Async={},Sync={}}local function j(k)if nil==k then return{['']=''}end;assert(type(k)=="table","A table is expected")if next(k)==nil then return{['']=''}end;return k end;function MySQL.Sync.execute(l,k)assert(type(l)=="string"or type(l)=="number","The SQL Query must be a string")local m=0;local n=false;exports['mysql-async']:mysql_execute(l,j(k),function(o)m=o;n=true end)repeat Citizen.Wait(0)until n==true;return m end;function MySQL.Sync.fetchAll(l,k)assert(type(l)=="string"or type(l)=="number","The SQL Query must be a string")local m={}local n=false;exports['mysql-async']:mysql_fetch_all(l,j(k),function(o)m=o;n=true end)repeat Citizen.Wait(0)until n==true;return m end;function MySQL.Sync.fetchScalar(l,k)assert(type(l)=="string"or type(l)=="number","The SQL Query must be a string")local m=''local n=false;exports['mysql-async']:mysql_fetch_scalar(l,j(k),function(o)m=o;n=true end)repeat Citizen.Wait(0)until n==true;return m end;function MySQL.Sync.insert(l,k)assert(type(l)=="string"or type(l)=="number","The SQL Query must be a string")local m=0;local n=false;exports['mysql-async']:mysql_insert(l,j(k),function(o)m=o;n=true end)repeat Citizen.Wait(0)until n==true;return m end;function MySQL.Sync.store(l)assert(type(l)=="string","The SQL Query must be a string")local m=-1;local n=false;exports['mysql-async']:mysql_store(l,function(o)m=o;n=true end)repeat Citizen.Wait(0)until n==true;return m end;function MySQL.Sync.transaction(p,k)local m=0;local n=false;exports['mysql-async']:mysql_transaction(p,k,function(o)m=o;n=true end)repeat Citizen.Wait(0)until n==true;return m end;function MySQL.Async.execute(l,k,q)assert(type(l)=="string"or type(l)=="number","The SQL Query must be a string")exports['mysql-async']:mysql_execute(l,j(k),q)end;function MySQL.Async.fetchAll(l,k,q)assert(type(l)=="string"or type(l)=="number","The SQL Query must be a string")exports['mysql-async']:mysql_fetch_all(l,j(k),q)end;function MySQL.Async.fetchScalar(l,k,q)assert(type(l)=="string"or type(l)=="number","The SQL Query must
|