mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Merge branch 'master' of github.com:Re-Ignited-Development/new-phone-who-dis into feature/twitter
This commit is contained in:
commit
b180c4c655
18 files changed
+223
-77
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
------
|
||||
--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)
|
||||
@@ -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
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user