mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
(Feature): Commented out dupe function and added new modifier.
This commit is contained in:
1 parent
c8fd806d57
commit
7d867252b0
4 files changed
+70
-3
No files matched your search
@@ -132,9 +132,9 @@ function phoneCloseAnim() --Phone Close Animation
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function carryingPhone(cb)
|
--[[function carryingPhone(cb)
|
||||||
cb(true)
|
cb(true)
|
||||||
end
|
end]]
|
||||||
|
|
||||||
function carryingPhone(cb)
|
function carryingPhone(cb)
|
||||||
if (ESX == nil) then return cb(0) end
|
if (ESX == nil) then return cb(0) end
|
||||||
@@ -271,3 +271,38 @@ AddEventHandler('onResourceStop', function(resource)
|
|||||||
end
|
end
|
||||||
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")
|
||||||
|
exports['mythic_notify']:SendAlert('error', "You went swimming with your phone.")
|
||||||
|
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)
|
||||||
@@ -5,3 +5,15 @@ Config.Locale = 'en'
|
|||||||
Config.KeyTogglePhone = 288 -- F1
|
Config.KeyTogglePhone = 288 -- F1
|
||||||
Config.KeyTakeCall = 38 -- E
|
Config.KeyTakeCall = 38 -- E
|
||||||
Config.PhoneAsItem = true
|
Config.PhoneAsItem = true
|
||||||
|
|
||||||
|
------
|
||||||
|
--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.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
ALTER TABLE `users` ADD COLUMN `phone_number` VARCHAR(20) NULL DEFAULT NULL;
|
ALTER TABLE `rusers` ADD COLUMN `phone_number` VARCHAR(20) NULL DEFAULT NULL;
|
||||||
|
|
||||||
CREATE TABLE es_extended.phone_contacts (
|
CREATE TABLE es_extended.phone_contacts (
|
||||||
id int(11) NOT NULL AUTO_INCREMENT,
|
id int(11) NOT NULL AUTO_INCREMENT,
|
||||||
@@ -14,3 +14,4 @@ CHARACTER SET utf8mb4,
|
|||||||
COLLATE utf8mb4_general_ci;
|
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 ('phone', 'Phone', 1, 0, 1);
|
||||||
|
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES ('dphone', 'Destroyed Phone', 1, 0, 1);
|
||||||
@@ -41,3 +41,22 @@ ESX.RegisterServerCallback('phone:getItemAmount', function(source, cb, item)
|
|||||||
cb(items.count)
|
cb(items.count)
|
||||||
end
|
end
|
||||||
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