diff --git a/phone/public/media/frames/s10.png b/phone/public/media/frames/s10.png index a25e604..1dfb38b 100644 Binary files a/phone/public/media/frames/s10.png and b/phone/public/media/frames/s10.png differ diff --git a/phone/public/media/frames/samsung.png b/phone/public/media/frames/samsung.png new file mode 100644 index 0000000..6861a22 Binary files /dev/null and b/phone/public/media/frames/samsung.png differ diff --git a/phone/public/media/frames/tw.png b/phone/public/media/frames/tw.png new file mode 100644 index 0000000..85775e9 Binary files /dev/null and b/phone/public/media/frames/tw.png differ diff --git a/phone/src/Phone.js b/phone/src/Phone.js index 1af3a73..c84c01d 100644 --- a/phone/src/Phone.js +++ b/phone/src/Phone.js @@ -4,8 +4,7 @@ import "./i18n"; import { Route } from "react-router-dom"; import { useSettings } from "./apps/settings/hooks/useSettings"; import MessageIcon from "@material-ui/icons/Email"; - -import Nui from "./os/nui-events/utils/Nui" +import { CallModal } from "./modal/components/CallModal"; import { HomeApp } from "./apps/home/components/Home"; import { ThemeProvider } from "@material-ui/core"; import { useInitKeyboard } from "./os/keyboard/hooks/useKeyboard"; @@ -20,53 +19,53 @@ import { useApps } from "./os/apps/hooks/useApps"; import { useContactsService } from "./apps/contacts/hooks/useContactsService"; import { useTwitterService } from "./apps/twitter/hooks/useTwitterService"; -// These events are just for testing. Comment it out before building. -//setTimeout(() => { -// window.dispatchEvent( -// new MessageEvent("message", { -// data: { -// app: "SIMCARD", -// method: "setNumber", -// data: "111-1134", -// }, -// }) -// ); -//}, 1000); +//These events are just for testing. Comment it out before building. +setTimeout(() => { + window.dispatchEvent( + new MessageEvent("message", { + data: { + app: "SIMCARD", + method: "setNumber", + data: "111-1134", + }, + }) + ); +}, 1000); -//setTimeout(() => { -// window.dispatchEvent( -// new MessageEvent("message", { -// data: { -// app: "BANK", -// method: "setContacts", -// data: [ -// { -// id: 1, -// number: "345-4366", -// display: "Kevin", -// }, -// { -// id: 2, -// number: "345-4366", -// display: "Kevin", -// }, -// ], -// }, -// }) -// ); -//}, 1000); +setTimeout(() => { + window.dispatchEvent( + new MessageEvent("message", { + data: { + app: "BANK", + method: "setContacts", + data: [ + { + id: 1, + number: "345-4366", + display: "Kevin", + }, + { + id: 2, + number: "345-4366", + display: "Kevin", + }, + ], + }, + }) + ); +}, 1000); -//setTimeout(() => { -// window.dispatchEvent( -// new MessageEvent("message", { -// data: { -// app: "PHONE", -// method: "setVisibility", -// data: true, -// }, -// }) -// ); -//}, 1000); +setTimeout(() => { + window.dispatchEvent( + new MessageEvent("message", { + data: { + app: "PHONE", + method: "setVisibility", + data: true, + }, + }) + ); +}, 1000); function Phone() { useNuiService(); @@ -82,6 +81,8 @@ function Phone() { return null; } + const calling = false; + return (
@@ -110,10 +111,17 @@ function Phone() { ]} />
- - {allApps.map((App) => ( - - ))} + {calling ? ( + + ) : ( + <> + + + {allApps.map((App) => ( + + ))} + + )}
diff --git a/phone/src/apps/example/components/ExampleApp.js b/phone/src/apps/example/components/ExampleApp.js new file mode 100644 index 0000000..52ac15f --- /dev/null +++ b/phone/src/apps/example/components/ExampleApp.js @@ -0,0 +1,18 @@ +import React from "react"; + +import { AppWrapper } from "../../../ui/components"; +import { AppTitle } from "../../../ui/components/AppTitle"; +import { AppContent } from "../../../ui/components/AppContent"; +import { useApp } from "../../../os/apps/hooks/useApps"; + +export const ExampleApp = () => { + const example = useApp("EXAMPLE"); + return ( + + + +

This is an example

+
+
+ ); +}; diff --git a/phone/src/apps/settings/default.json b/phone/src/apps/settings/default.json index d864924..01d3d2a 100644 --- a/phone/src/apps/settings/default.json +++ b/phone/src/apps/settings/default.json @@ -1,5 +1,5 @@ { - "wallpaper": "default.png", - "frame": "default.png", - "theme": "default-dark" -} \ No newline at end of file + "wallpaper": "default.png", + "frame": "s10.png", + "theme": "default-dark" +} diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json index bfb1e4d..a9fe2a9 100644 --- a/phone/src/locale/en.json +++ b/phone/src/locale/en.json @@ -7,6 +7,7 @@ "APPS_CALCULATOR": "Calculator", "APPS_SETTINGS": "Settings", "APPS_BANK": "WhoDis Banking", + "APPS_EXAMPLE": "Example app", "APPS_BANK_DEPOSIT": "Deposit", "APPS_BANK_WITHDRAW": "Withdraw", "APPS_BANK_TRANSFER": "Transfer", diff --git a/phone/src/modal/components/CallModal.js b/phone/src/modal/components/CallModal.js new file mode 100644 index 0000000..2943c57 --- /dev/null +++ b/phone/src/modal/components/CallModal.js @@ -0,0 +1,24 @@ +import React from "react"; +import { makeStyles } from "@material-ui/core"; +import { AppWrapper } from "../../ui/components/AppWrapper"; +import { AppTitle } from "../../ui/components/AppTitle"; +import { AppContent } from "../../ui/components/AppContent"; +import { Button } from "../../ui/components/Button"; + +export const CallModal = () => { + return ( + + + +

+ Call +

+
+
+ ); +}; diff --git a/phone/src/modal/hooks/state.js b/phone/src/modal/hooks/state.js new file mode 100644 index 0000000..d56c306 --- /dev/null +++ b/phone/src/modal/hooks/state.js @@ -0,0 +1,8 @@ +import { atom } from "recoil"; + +export const callerState = { + caller: atom({ + key: "callerList", + default: [], + }), +}; diff --git a/phone/src/modal/hooks/useCall.js b/phone/src/modal/hooks/useCall.js new file mode 100644 index 0000000..ad3e70d --- /dev/null +++ b/phone/src/modal/hooks/useCall.js @@ -0,0 +1,7 @@ +import { useRecoilValue } from "recoil"; +import { callerState } from "./state"; + +export const useCall = () => { + const caller = useRecoilState(callerState.caller); + return { caller }; +}; diff --git a/phone/src/modal/hooks/useCallService.js b/phone/src/modal/hooks/useCallService.js new file mode 100644 index 0000000..e97a5cb --- /dev/null +++ b/phone/src/modal/hooks/useCallService.js @@ -0,0 +1,10 @@ +import { useNuiEvent } from "../../os/nui-events/hooks/useNuiEvent"; +import { useSetRecoilState } from "recoil"; +import { callerState } from "./state"; +import { useCall } from "./useCall"; + +export const useCallService = () => { + const setCaller = useSetRecoilState(callerState.caller); + useNuiEvent("CALL", "setCaller", setCaller); + return useCall(); +}; diff --git a/phone/src/os/apps/hooks/useApps.js b/phone/src/os/apps/hooks/useApps.js index fb67a71..dbdec36 100644 --- a/phone/src/os/apps/hooks/useApps.js +++ b/phone/src/os/apps/hooks/useApps.js @@ -12,6 +12,7 @@ import { import ContactsIcon from "@material-ui/icons/Contacts"; import SettingsIcon from "@material-ui/icons/Settings"; import PhoneIcon from "@material-ui/icons/Phone"; +import CalendarTodayIcon from "@material-ui/icons/CalendarToday"; import AccountBalanceIcon from "@material-ui/icons/AccountBalance"; import MessageIcon from "@material-ui/icons/Message"; import TwitterIcon from "@material-ui/icons/Twitter"; @@ -25,6 +26,7 @@ import { SettingsApp } from "../../../apps/settings/components/SettingsApp"; import { BankApp } from "../../../apps/bank/components/BankApp"; import { MessagesApp } from "../../../apps/messages/components/MessagesApp"; import { TwitterApp } from "../../../apps/twitter/components/TwitterApp"; +import { ExampleApp } from "../../../apps/example/components/ExampleApp"; const appsState = atom({ key: "apps", @@ -93,6 +95,15 @@ const appsState = atom({ path: "/twitter", Route: () => , }, + { + id: "EXAMPLE", + nameLocale: "APPS_EXAMPLE", + icon: , + backgroundColor: blue[500], + color: blue[50], + path: "/example", + Route: () => , + }, ], }, }); diff --git a/resources/client/cl_call.lua b/resources/client/cl_call.lua index c50509c..156d825 100644 --- a/resources/client/cl_call.lua +++ b/resources/client/cl_call.lua @@ -18,7 +18,7 @@ RegisterNUICallback('phone:startCall', function(data) startCall(phoneNumber) end) -RegisterNetEvent("phone:acceptCall") +--[[RegisterNetEvent("phone:acceptCall") AddEventHandler("phone:acceptCall", function(phoneNumber, initiator) print("should accept") if inCall == false then @@ -42,17 +42,17 @@ AddEventHandler("phone:acceptCall", function(phoneNumber, initiator) SetNuiFocus(true, true) TriggerServerEvent('phone:getCredentials', source) end -end) +end)--]] RegisterCommand('answer', function(source) -- Toggles Phone local rocko = 2222222 local chip = 1111111 - acceptCall (rocko) + acceptCall(rocko, chip) print(rocko) end, false) -function startCall (phoneNumber) - TriggerServerEvent('phone:startCall', phoneNumber) +function startCall(transmitter, target) + TriggerServerEvent('phone:startCall', transmitter, target) end function acceptCall (phoneNumber) diff --git a/resources/client/cl_main.lua b/resources/client/cl_main.lua index 428e9e8..833c9f7 100644 --- a/resources/client/cl_main.lua +++ b/resources/client/cl_main.lua @@ -132,9 +132,9 @@ function phoneCloseAnim() --Phone Close Animation end end -function carryingPhone(cb) +--[[function carryingPhone(cb) cb(true) -end +end]] function carryingPhone(cb) if (ESX == nil) then return cb(0) end @@ -147,7 +147,7 @@ function noPhone() if (ESX == nil) then return end --exports['mythic_notify']:SendAlert('error', 'Oi Mate, No El Telephono') ESX.ShowNotification('Oi Mate, No El Telephono') - end +end Citizen.CreateThread(function() while true do @@ -281,4 +281,39 @@ AddEventHandler('onResourceStop', function(resource) ClearPedTasks(GetPlayerPed(-1)) -- Leave here until launch as it'll fix any stuck animations. end end) - \ No newline at end of file + +------ +--Phone Destory When Wet +------ + +function countPhone(cb) + if (ESX == nil) then + return cb(0) + end + ESX.TriggerServerCallback('phone:removephone', function(qtty) + cb(qtty > 0) + end, 'phone') +end + +local destroyedPhone = false + +Citizen.CreateThread(function() + while Config.SwimDestroy do -- Checks if phone should destroy while swimming. + Citizen.Wait(Config.RunRate * 1000) -- Checks how often the player is swimming x * 1 second. + if IsPedSwimming(GetPlayerPed(-1)) then + local chance = GetRandomIntInRange(0, 100) + if chance <= Config.DestoryChance then -- Chance of destroying the phone. + countPhone(function (countPhone) + if countPhone == true then + --print("Phone destroyed") + ESX.ShowNotification('Your phone is ruined from the water!') + destroyedPhone = true + end + end) + end + if destroyedPhone == true then -- If the phone was destroyed earlier then we will wait to check again. + Wait(Config.DestroyPhoneReCheck * 60000) -- Waits x * 1 minute before checking again because it's pointless to re check. + end + end + end +end) \ No newline at end of file diff --git a/resources/config.lua b/resources/config.lua index c6487dd..a942615 100644 --- a/resources/config.lua +++ b/resources/config.lua @@ -6,6 +6,22 @@ Config.KeyTogglePhone = 288 -- F1 Config.KeyTakeCall = 38 -- E Config.PhoneAsItem = false +------ +--Destroy Phone +------ + +Config.SwimDestroy = false --only set true if you have PhoneAsItem. + +Config.RunRate = 10 --SECONDS /// Will do the initial thread every X SECONDS to check if the player is swimming so the phone can be destroyed based off the chance below. + +Config.DestoryChance = 100 --PERCENT BASED /// from 0 to 100 where 100 is equal to 100% chance and 10 is equal to 10%. This is dependent on the amount above so dont set it too low. + +Config.DestroyPhoneReCheck = 3 --MINUTES /// WIll wait the check for x MINUTES as they have no phone now and have been given a destroyed phone = to the number of phones they had. + + +------ +--Twitter +------ Config.twitter = {} -- Config.twitter.registerByName = true -- if users can register by first_name and last_name from the users table -- Config.twitter.registerByPhoneNumber = true -- if users can register by phone_number from the users table @@ -16,3 +32,4 @@ Config.twitter.enableAvatars = true -- whether or not player avatars are visible Config.twitter.enableEmojis = true -- whether or not the emoji menu is available Config.twitter.enableImages = true -- whether or not links to images are rendered on the UI and if players can add new ones Config.twitter.maxImages = 3 -- max amount of images that can be attached to a single tweet +Config.PhoneAsItem = true \ No newline at end of file diff --git a/resources/import.sql b/resources/import.sql index 1ca1505..cd8772c 100644 --- a/resources/import.sql +++ b/resources/import.sql @@ -14,6 +14,7 @@ CHARACTER SET utf8mb4, COLLATE utf8mb4_general_ci; INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES ('phone', 'Phone', 1, 0, 1); +INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES ('dphone', 'Destroyed Phone', 1, 0, 1); CREATE TABLE `npwd_twitter_tweets` ( `id` int NOT NULL AUTO_INCREMENT, diff --git a/resources/server/sv_call.lua b/resources/server/sv_call.lua index d116c9c..4032733 100644 --- a/resources/server/sv_call.lua +++ b/resources/server/sv_call.lua @@ -100,16 +100,3 @@ AddEventHandler('phone:initalizeCall', function(source, phoneNumber) end) -RegisterServerEvent('phone:acceptCall') -AddEventHandler('phone:acceptCall', function(source, phoneNumber) - if phoneNumber ~= nil then - getSourceFromIdentifier(zPlayer, function (target) - if target ~= nil then - TriggerClientEvent('phone:acceptCall', sourcePlayer, phoneNumber, true) - TriggerClientEvent('phone:acceptCall', target, phoneNumber, false) - else - TriggerClientEvent('phone:acceptCall', sourcePlayer, phoneNumber, true) - end - end) - end -end) \ No newline at end of file diff --git a/resources/server/sv_main.lua b/resources/server/sv_main.lua index 398671c..1689f07 100644 --- a/resources/server/sv_main.lua +++ b/resources/server/sv_main.lua @@ -47,4 +47,23 @@ ESX.RegisterServerCallback('phone:getItemAmount', function(source, cb, item) else cb(items.count) end +end) + +---- +--Destroy Phone +-- + +ESX.RegisterServerCallback('phone:removephone', function(source, cb, item) + local xPlayer = ESX.GetPlayerFromId(source) + local items = xPlayer.getInventoryItem(item) + + if items == nil then + cb(0) + else + cb(items.count) + if items.count > 0 then + xPlayer.removeInventoryItem('phone', items.count) + xPlayer.addInventoryItem('dphone', items.count) + end + end end) \ No newline at end of file