Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework adjustable version - default esx #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update README.md
Update camera.lua

Update contact.lua

Update emails.lua

Update garages.lua

Update garages.lua

Update garages.lua

Update garages.lua

Update houses.lua

Update main.lua

Update notification.lua

Update photos.lua

Update services.lua

Update services.lua

Update fxmanifest.lua

Update ads.lua

Update bank.lua

Update calls.lua

Update chat.lua

Update contact.lua

Update emails.lua

Update houses.lua

Update inetmax.lua

Update loops.lua

Update main.lua

Update news.lua

Update photos.lua

Update profile.lua

Update services.lua

Update README.md

Update profile.lua

Update main.lua

Update camera.lua

Update emails.lua

Update emails.lua

Update main.lua

Update services.lua

Update services.lua

Update main.lua

Update ads.lua

Update config.lua

Update ads.lua

Update bank.lua

Update calls.lua

Update chat.lua

Update contact.lua

Update ads.lua

Update config.lua

Update bank.lua

Delete server directory

Add files via upload

dified:   server/emails.lua
Hajdenko committed Oct 6, 2024
commit 83d9f51418b271be22a873c0230887462c9852eb
51 changes: 4 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -12,9 +12,10 @@ This project is inspired by **QBPhone** from **QBCore**, combining its core func

## Dependencies

- **[QB Core](https://github.com/qbcore-framework/qb-core "QB Core")**: This project relies on the QBCore framework for core functionalities.
- **[QB Banking](https://github.com/qbcore-framework/qb-banking "QB Banking")**: QB Banking is need for digital banking app.
- **[ESX Core](https://github.com/esx-framework/esx_core "ESX Core")**: This project relies on the ESX framework for core functionalities.
- here was a dependency for qb_banking, you do not need esx_banking for this version.
- **[OX Lib](https://github.com/overextended/ox_lib "OX Lib")**: OX Lib is also required to ensure seamless integration with existing systems.
- **[OX Inventory](https://github.com/overextended/ox_inventory "OX Inventory")**: OX Inventory is also required for item handling.

## Tech Stack

@@ -39,50 +40,6 @@ Thank you for checking out Z-Phone! We hope you enjoy the new experience as much

## Ready to Use???

#### (Optional) **BANK TRANSACTION**

If you want all bank transactions recorded, then do it
in **qb-core/server/player.lua**

**function self.Functions.AddMoney**

```lua
-- OTHERS CODE
if not self.Offline then
-- OTHERS CODE
if moneytype == 'bank' then
MySQL.Async.insert('INSERT INTO bank_statements (citizenid, account_name, amount, reason, statement_type) VALUES (?, ?, ?, ?, ?)', {
self.PlayerData.citizenid,
'checking',
amount,
reason,
'deposit'
})
end
-- OTHERS CODE
end
```

**self.Functions.RemoveMoney**

```lua
-- OTHERS CODE
if not self.Offline then
-- OTHERS CODE
if moneytype == 'bank' then
MySQL.Async.insert('INSERT INTO bank_statements (citizenid, account_name, amount, reason, statement_type) VALUES (?, ?, ?, ?, ?)', {
self.PlayerData.citizenid,
'checking',
amount,
reason,
'withdraw'
})
TriggerClientEvent('qb-phone:client:RemoveBankMoney', self.PlayerData.source, amount)
end
-- OTHERS CODE
end
```

#### (Required) **IMPORT SOUND**

Go to https://github.com/alfaben12/z-phone/tree/main/html/sounds copy all files then paste to resources/[standalone]/interact-sound/client/html/sounds
@@ -100,7 +57,7 @@ This query included on z-phone.sql

## IMPORTANT NOTES

Default phone number in QBCore may not be compatible with z-phone. If you use QBCore.Functions.GetPlayerByPhone(number) with a z-phone number, it is likely to return incorrect results. To avoid this issue, it's essential to synchronize the z-phone numbers with the QBCore character information (on table players, column charinfo, key phone).
Here was note for changing the phone number, but in this version it generates a new phone number for each person

## BTW

9 changes: 6 additions & 3 deletions client/camera.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local QBCore = exports['qb-core']:GetCoreObject()
local frontCam = false

local function SaveToInternalGallery()
@@ -33,7 +32,11 @@ RegisterNUICallback('TakePhoto', function(_, cb)
elseif IsControlJustPressed(1, 176) then -- TAKE.. PIC
lib.callback('z-phone:server:GetWebhook', false, function(hook)
if not hook then
QBCore.Functions.Notify('Camera not setup', 'error')
lib.notify({
title = 'Camera',
description = 'Camera not setup',
type = 'error'
})
return
end
exports['screenshot-basic']:requestScreenshotUpload(tostring(hook), 'files[]', function(data)
@@ -63,4 +66,4 @@ RegisterNUICallback('TakePhoto', function(_, cb)
else
DoPhoneAnimation('cellphone_call_to_text')
end
end)
end)
15 changes: 12 additions & 3 deletions client/contact.lua
Original file line number Diff line number Diff line change
@@ -29,10 +29,19 @@ RegisterNUICallback('get-contact-requests', function(_, cb)
end)

RegisterNUICallback('share-contact', function(body, cb)
local closestPlayer, distance = QBCore.Functions.GetClosestPlayer()
local closestPlayer = lib.getClosestPlayer(GetEntityCoords(cache.ped), 10.0, false)
if ( not closestPlayer ) then
TriggerEvent("z-phone:client:sendNotifInternal", {
type = "Notification",
from = "Contact",
message = "Cannot share contact!"
})
return
end
local distance = #(vec3(closestPlayer.coords.x, closestPlayer.coords.y, closestPlayer.coords.z) - GetEntityCoords(cache.ped))
local ped = PlayerPedId()

if not (distance ~= -1 and distance < 2 and GetEntitySpeed(ped) < 5.0 and not QBCore.Functions.GetPlayerData().metadata.ishandcuffed and not IsPedRagdoll(ped)) then
if not (distance ~= -1 and distance < 2 and GetEntitySpeed(ped) < 5.0 and not IsPedCuffed(ped) and not IsPedRagdoll(ped)) then
TriggerEvent("z-phone:client:sendNotifInternal", {
type = "Notification",
from = "Contact",
@@ -57,4 +66,4 @@ RegisterNUICallback('delete-contact-requests', function(body, cb)
lib.callback('z-phone:server:DeleteContactRequest', false, function(isOk)
cb(isOk)
end, body)
end)
end)
4 changes: 2 additions & 2 deletions client/emails.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
RegisterNUICallback('get-emails', function(_, cb)
lib.callback('z-phone:server:GetEmails', false, function(emails)
for i, v in pairs(emails) do
local job = QBCore.Shared.Jobs[v.institution]
local job = Config.Framework.GetJobs()[v.institution]
emails[i].avatar = 'https://raw.githubusercontent.com/alfaben12/kmrp-assets/main/logo/business/'.. v.institution ..'.png'
emails[i].name = job and job.label or v.institution:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end)
end
cb(emails)
end)
end)
end)
14 changes: 6 additions & 8 deletions client/garages.lua
Original file line number Diff line number Diff line change
@@ -2,15 +2,13 @@ RegisterNUICallback('get-garages', function(_, cb)
lib.callback('z-phone:server:GetVehicles', false, function(vehicles)
local VehiclesFormatted = {}
for _, v in pairs(vehicles) do
local VehicleData = QBCore.Shared.Vehicles[v.vehicle]

VehiclesFormatted[#VehiclesFormatted + 1] = {
name = VehicleData['name'] or 'Unknown Vehicle',
name = v.model or 'Unknown Vehicle', -- Use vehicle model directly
image = "https://raw.githubusercontent.com/alfaben12/kmrp-assets/main/images/".. v.vehicle ..".png",
brand = VehicleData and VehicleData['brand'] or '',
model = VehicleData and VehicleData['model'] or '',
type = VehicleData and VehicleData['type'] or '',
category = VehicleData and VehicleData['category'] or '',
brand = v.brand or '',
model = v.model or '',
type = v.type or '',
category = v.category or '',
plate = v.plate,
garage = v.garage,
state = v.state,
@@ -22,4 +20,4 @@ RegisterNUICallback('get-garages', function(_, cb)
end
cb(VehiclesFormatted)
end)
end)
end)
8 changes: 6 additions & 2 deletions client/houses.lua
Original file line number Diff line number Diff line change
@@ -11,6 +11,10 @@ end)

RegisterNUICallback('get-direction', function(body, cb)
SetNewWaypoint(body.coords.enter.x, body.coords.enter.y)
QBCore.Functions.Notify('GPS has been set to ' .. body.name .. '!', 'success')
lib.notify({
title = 'GPS',
description = 'GPS has been set to ' .. body.name .. '!',
type = 'success'
})
cb("ok")
end)
end)
79 changes: 62 additions & 17 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
QBCore = exports['qb-core']:GetCoreObject()
PlayerJob = {}
Profile = {}
PhoneData = {
@@ -27,12 +26,50 @@ CreateThread(function()
end
end)

RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
lib.callback('z-phone:server:GetProfile', false, function(profile)
profile.signal = Config.Signal.Zones[PhoneData.SignalZone].ChanceSignal
Profile = profile
end)
end)
loadFrameworkEvents = function()
es_extended = GetResourceState('es_extended') == 'started';
qb_core = GetResourceState('qb-core') == 'started';
qbx_core = GetResourceState('qbx_core') == 'started';
if ( es_extended ) then
RegisterNetEvent('esx:playerLoaded', function(player, xPlayer, isNew)
lib.callback('z-phone:server:GetProfile', false, function(profile)
profile.signal = Config.Signal.Zones[PhoneData.SignalZone].ChanceSignal
Profile = profile
end)
end)

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
PlayerJob = JobInfo
end)
elseif ( qb_core ) then
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
lib.callback('z-phone:server:GetProfile', false, function(profile)
profile.signal = Config.Signal.Zones[PhoneData.SignalZone].ChanceSignal
Profile = profile
end)
end)

RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
PlayerJob = JobInfo
end)
elseif ( qbx_core ) then
AddEvent('qbox:client:OnPlayerLoaded', function()
lib.callback('z-phone:server:GetProfile', false, function(profile)
profile.signal = Config.Signal.Zones[PhoneData.SignalZone].ChanceSignal
Profile = profile
end)
end)

AddEvent('qbox:client:OnJobUpdate', function(JobInfo)
PlayerJob = JobInfo
end)
else
warn("No framework core found.")
end
end

CreateThread(loadFrameworkEvents)

function GetStreetName()
local pos = GetEntityCoords(PlayerPedId())
@@ -47,10 +84,6 @@ function GetStreetName()
return streetLabel
end

RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
PlayerJob = JobInfo
end)

local function DisableDisplayControlActions()
DisableControlAction(0, 1, true) -- disable mouse look
DisableControlAction(0, 2, true) -- disable mouse look
@@ -75,13 +108,17 @@ end
function OpenPhone()
local hasWeapon, weaponHash = GetCurrentPedWeapon(PlayerPedId(), true)
if weaponHash ~= GetHashKey("WEAPON_UNARMED") then
QBCore.Functions.Notify("Cannot open radio!", 'error')
lib.notify({
title = 'Radio',
description = "Cannot open radio!",
type = 'error'
})
return
end

lib.callback('z-phone:server:HasPhone', false, function(HasPhone)
if HasPhone then
PhoneData.PlayerData = QBCore.Functions.GetPlayerData()
PhoneData.PlayerData = Config.Framework.GetPlayerData()
SetNuiFocus(true, true)
-- SetNuiFocusKeepInput(true)
SendNUIMessage({
@@ -107,18 +144,26 @@ function OpenPhone()
newPhoneProp()
end)
else
QBCore.Functions.Notify("You don't have a phone", 'error')
lib.notify({
title = 'No Phone',
description = "You don't have a phone",
type = 'error'
})
end
end)
end

RegisterCommand('phone', function()
local PlayerData = QBCore.Functions.GetPlayerData()
local PlayerData = Config.Framework.GetPlayerData()
if not PhoneData.isOpen and LocalPlayer.state.isLoggedIn then
if not PlayerData.metadata['ishandcuffed'] and not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] and not IsPauseMenuActive() then
OpenPhone()
else
QBCore.Functions.Notify('Action not available at the moment..', 'error')
lib.notify({
title = 'Phone',
description = 'Action not available at the moment..',
type = 'error'
})
end
end
end)
@@ -152,4 +197,4 @@ RegisterNUICallback('close', function(_, cb)
PhoneData.isOpen = false
end)
cb('ok')
end)
end)
36 changes: 30 additions & 6 deletions client/notification.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
hasPhone = function()
local items = exports.ox_inventory:GetPlayerItems()

for _, item in pairs(items) do
if item.name == 'phone' then
return true
end
end

return false
end


RegisterNetEvent('z-phone:client:sendNotifMessage', function(message)
TriggerServerEvent('InteractSound_SV:PlayOnSource', 'monkeyopening', 0.2)
if QBCore.Functions.HasItem('phone') then

if hasPhone() then
if PhoneData.isOpen then
SendNUIMessage({
event = 'z-phone',
@@ -25,7 +39,7 @@ RegisterNetEvent('z-phone:client:sendNotifMessage', function(message)
end)

RegisterNetEvent('z-phone:client:sendNotifInternal', function(message)
if QBCore.Functions.HasItem('phone') then
if hasPhone() then
if PhoneData.isOpen then
SendNUIMessage({
event = 'z-phone',
@@ -36,7 +50,17 @@ RegisterNetEvent('z-phone:client:sendNotifInternal', function(message)
},
})
else
QBCore.Functions.Notify(string.format("[%s] %s", message.from, message.message))
local lib_notify_map = {
error = 'error',
warning = 'warning',
success = 'success'
}

lib.notify({
title = 'Phone',
description = string.format("[%s] %s", message.from,
type = lib_notify_map[message.message] or 'inform'
})
end
end
end)
@@ -45,7 +69,7 @@ RegisterNetEvent('z-phone:client:sendNotifIncomingCall', function(message)
PhoneData.CallData.InCall = true
PhoneData.CallData.CallId = message.call_id

if QBCore.Functions.HasItem('phone') then
if hasPhone() then
if PhoneData.isOpen then
SendNUIMessage({
event = 'z-phone',
@@ -109,7 +133,7 @@ RegisterNetEvent('z-phone:client:sendNotifIncomingCall', function(message)
end)

RegisterNetEvent('z-phone:client:sendNotifStartCall', function(message)
if QBCore.Functions.HasItem('phone') then
if hasPhone() then
SendNUIMessage({
event = 'z-phone',
notification = {
@@ -182,4 +206,4 @@ RegisterNetEvent('z-phone:client:closeCallSelf', function()
type = "CLOSE_CALL",
},
})
end)
end)
Loading