mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Add files
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
||||
|
||||
description 'ESX Property'
|
||||
|
||||
server_scripts {
|
||||
'@mysql-async/lib/MySQL.lua',
|
||||
'config.lua',
|
||||
'server/main.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
+1024
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
Config = {}
|
||||
Config.DrawDistance = 100
|
||||
Config.MarkerSize = {x = 1.5, y = 1.5, z = 1.0}
|
||||
Config.MarkerColor = {r = 102, g = 102, b = 204}
|
||||
Config.RoomMenuMarkerColor = {r = 102, g = 204, b = 102}
|
||||
Config.MarkerType = 1
|
||||
Config.Zones = {}
|
||||
Config.Properties = {}
|
||||
Config.EnablePlayerManagement = false -- If set to true you need esx_realestateagentjob
|
||||
@@ -0,0 +1,76 @@
|
||||
CREATE TABLE `owned_properties` (
|
||||
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`price` double NOT NULL,
|
||||
`rented` int(11) NOT NULL,
|
||||
`owner` varchar(60) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
CREATE TABLE `properties` (
|
||||
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`label` varchar(255) DEFAULT NULL,
|
||||
`entering` varchar(255) DEFAULT NULL,
|
||||
`exit` varchar(255) DEFAULT NULL,
|
||||
`inside` varchar(255) DEFAULT NULL,
|
||||
`outside` varchar(255) DEFAULT NULL,
|
||||
`ipls` varchar(255) DEFAULT '[]',
|
||||
`gateway` varchar(255) DEFAULT NULL,
|
||||
`is_single` int(11) DEFAULT NULL,
|
||||
`is_room` int(11) DEFAULT NULL,
|
||||
`is_gateway` int(11) DEFAULT NULL,
|
||||
`room_menu` varchar(255) DEFAULT NULL,
|
||||
`price` int(11) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
INSERT INTO `properties` VALUES
|
||||
(1,'WhispymoundDrive','2677 Whispymound Drive','{\"y\":564.89,\"z\":182.959,\"x\":119.384}','{\"y\":558.667,\"z\":183.297,\"x\":116.392}','{\"y\":557.032,\"z\":183.301,\"x\":118.037}','{\"y\":567.798,\"z\":182.131,\"x\":119.249}','[]',NULL,1,1,0,'{\"x\":118.748,\"y\":566.573,\"z\":175.697}',1500000),
|
||||
(2,'NorthConkerAvenue2045','Milla House','{\"y\":834.47540283203,\"z\":234.92024230957,\"x\":-86.692153930664}','{\"y\":422.84088134766,\"z\":144.90005493164,\"x\":372.70159912109}','{\"y\":420.07595825195,\"z\":145.90487670898,\"x\":373.16149902344}','{\"y\":835.64111328125,\"z\":234.7230072021,\"x\":-90.789779663086}','[]',NULL,1,1,0,'{\"x\":377.349,\"y\":429.422,\"z\":137.3}',1500000),
|
||||
(3,'RichardMajesticApt2','Richard Majestic, Apt 2','{\"y\":-379.165,\"z\":37.961,\"x\":-936.363}','{\"y\":-365.476,\"z\":113.274,\"x\":-913.097}','{\"y\":-367.637,\"z\":113.274,\"x\":-918.022}','{\"y\":-382.023,\"z\":37.961,\"x\":-943.626}','[]',NULL,1,1,0,'{\"x\":-927.554,\"y\":-377.744,\"z\":112.674}',1700000),
|
||||
(4,'NorthConkerAvenue2044','2044 North Conker Avenue','{\"y\":440.8,\"z\":146.702,\"x\":346.964}','{\"y\":437.456,\"z\":148.394,\"x\":341.683}','{\"y\":435.626,\"z\":148.394,\"x\":339.595}','{\"y\":444.374,\"z\":145.037,\"x\":-212.15144348145}','[]',NULL,1,1,0,'{\"x\":337.726,\"y\":436.985,\"z\":140.77}',1500000),
|
||||
(5,'WildOatsDrive','3655 Wild Oats Drive','{\"y\":502.696,\"z\":136.421,\"x\":-176.003}','{\"y\":497.817,\"z\":136.653,\"x\":-174.349}','{\"y\":495.069,\"z\":136.666,\"x\":-173.331}','{\"y\":506.412,\"z\":135.0664,\"x\":-177.927}','[]',NULL,1,1,0,'{\"x\":-174.725,\"y\":493.095,\"z\":129.043}',1500000),
|
||||
(6,'HillcrestAvenue2862','2862 Hillcrest Avenue','{\"y\":596.58,\"z\":142.641,\"x\":-686.554}','{\"y\":591.988,\"z\":144.392,\"x\":-681.728}','{\"y\":590.608,\"z\":144.392,\"x\":-680.124}','{\"y\":599.019,\"z\":142.059,\"x\":-689.492}','[]',NULL,1,1,0,'{\"x\":-680.46,\"y\":588.6,\"z\":136.769}',1500000),
|
||||
(7,'LowEndApartment','Appartement de base','{\"y\":-1078.735,\"z\":28.4031,\"x\":292.528}','{\"y\":-1007.152,\"z\":-102.002,\"x\":265.845}','{\"y\":-1002.802,\"z\":-100.008,\"x\":265.307}','{\"y\":-1078.669,\"z\":28.401,\"x\":296.738}','[]',NULL,1,1,0,'{\"x\":265.916,\"y\":-999.38,\"z\":-100.008}',562500),
|
||||
(8,'MadWayneThunder','2113 Mad Wayne Thunder','{\"y\":454.955,\"z\":96.462,\"x\":-1294.433}','{\"y\":448.07,\"z\":96.894,\"x\":-1290.834}','{\"y\":446.322,\"z\":96.899,\"x\":-1289.642}','{\"y\":455.453,\"z\":96.517,\"x\":-1298.851}','[]',NULL,1,1,0,'{\"x\":-1287.306,\"y\":455.901,\"z\":89.294}',1500000),
|
||||
(9,'HillcrestAvenue2874','2874 Hillcrest Avenue','{\"y\":696.314,\"z\":147.784,\"x\":-853.282}','{\"y\":690.875,\"z\":151.86,\"x\":-859.961}','{\"y\":688.361,\"z\":151.857,\"x\":-859.395}','{\"y\":701.628,\"z\":147.773,\"x\":-855.007}','[]',NULL,1,1,0,'{\"x\":-858.543,\"y\":697.514,\"z\":144.253}',1500000),
|
||||
(10,'HillcrestAvenue2868','2868 Hillcrest Avenue','{\"y\":620.494,\"z\":141.588,\"x\":-752.82}','{\"y\":618.62,\"z\":143.153,\"x\":-759.317}','{\"y\":617.629,\"z\":143.153,\"x\":-760.789}','{\"y\":621.281,\"z\":141.254,\"x\":-750.919}','[]',NULL,1,1,0,'{\"x\":-762.504,\"y\":618.992,\"z\":135.53}',1500000),
|
||||
(11,'TinselTowersApt12','Tinsel Towers, Apt 42','{\"y\":37.025,\"z\":42.58,\"x\":-618.299}','{\"y\":58.898,\"z\":97.2,\"x\":-603.301}','{\"y\":58.941,\"z\":97.2,\"x\":-608.741}','{\"y\":30.603,\"z\":42.524,\"x\":-620.017}','[]',NULL,1,1,0,'{\"x\":-622.173,\"y\":54.585,\"z\":96.599}',1700000),
|
||||
(12,'MiltonDrive','Milton Drive','{\"x\":-775.17,\"y\":312.01,\"z\":84.658}',NULL,NULL,'{\"x\":-775.346,\"y\":306.776,\"z\":84.7}','[]',NULL,0,0,1,NULL,0),
|
||||
(13,'Modern1Apartment','Appartement Moderne 1',NULL,'{\"x\":-784.194,\"y\":323.636,\"z\":210.997}','{\"x\":-779.751,\"y\":323.385,\"z\":210.997}',NULL,'[\"apa_v_mp_h_01_a\"]','MiltonDrive',0,1,0,'{\"x\":-766.661,\"y\":327.672,\"z\":210.396}',1300000),
|
||||
(14,'Modern2Apartment','Appartement Moderne 2',NULL,'{\"x\":-786.8663,\"y\":315.764,\"z\":186.913}','{\"x\":-781.808,\"y\":315.866,\"z\":186.913}',NULL,'[\"apa_v_mp_h_01_c\"]','MiltonDrive',0,1,0,'{\"x\":-795.735,\"y\":326.757,\"z\":186.313}',1300000),
|
||||
(15,'Modern3Apartment','Appartement Moderne 3',NULL,'{\"x\":-774.012,\"y\":342.042,\"z\":195.686}','{\"x\":-779.057,\"y\":342.063,\"z\":195.686}',NULL,'[\"apa_v_mp_h_01_b\"]','MiltonDrive',0,1,0,'{\"x\":-765.386,\"y\":330.782,\"z\":195.08}',1300000),
|
||||
(16,'Mody1Apartment','Appartement Mode 1',NULL,'{\"x\":-784.194,\"y\":323.636,\"z\":210.997}','{\"x\":-779.751,\"y\":323.385,\"z\":210.997}',NULL,'[\"apa_v_mp_h_02_a\"]','MiltonDrive',0,1,0,'{\"x\":-766.615,\"y\":327.878,\"z\":210.396}',1300000),
|
||||
(17,'Mody2Apartment','Appartement Mode 2',NULL,'{\"x\":-786.8663,\"y\":315.764,\"z\":186.913}','{\"x\":-781.808,\"y\":315.866,\"z\":186.913}',NULL,'[\"apa_v_mp_h_02_c\"]','MiltonDrive',0,1,0,'{\"x\":-795.297,\"y\":327.092,\"z\":186.313}',1300000),
|
||||
(18,'Mody3Apartment','Appartement Mode 3',NULL,'{\"x\":-774.012,\"y\":342.042,\"z\":195.686}','{\"x\":-779.057,\"y\":342.063,\"z\":195.686}',NULL,'[\"apa_v_mp_h_02_b\"]','MiltonDrive',0,1,0,'{\"x\":-765.303,\"y\":330.932,\"z\":195.085}',1300000),
|
||||
(19,'Vibrant1Apartment','Appartement Vibrant 1',NULL,'{\"x\":-784.194,\"y\":323.636,\"z\":210.997}','{\"x\":-779.751,\"y\":323.385,\"z\":210.997}',NULL,'[\"apa_v_mp_h_03_a\"]','MiltonDrive',0,1,0,'{\"x\":-765.885,\"y\":327.641,\"z\":211.396}',1300000),
|
||||
(20,'Vibrant2Apartment','Appartement Vibrant 2',NULL,'{\"x\":-786.8663,\"y\":315.764,\"z\":186.913}','{\"x\":-781.808,\"y\":315.866,\"z\":186.913}',NULL,'[\"apa_v_mp_h_03_c\"]','MiltonDrive',0,1,0,'{\"x\":-795.607,\"y\":327.344,\"z\":186.313}',1300000),
|
||||
(21,'Vibrant3Apartment','Appartement Vibrant 3',NULL,'{\"x\":-774.012,\"y\":342.042,\"z\":195.686}','{\"x\":-779.057,\"y\":342.063,\"z\":195.686}',NULL,'[\"apa_v_mp_h_03_b\"]','MiltonDrive',0,1,0,'{\"x\":-765.525,\"y\":330.851,\"z\":195.085}',1300000),
|
||||
(22,'Sharp1Apartment','Appartement Pèrcant 1',NULL,'{\"x\":-784.194,\"y\":323.636,\"z\":210.997}','{\"x\":-779.751,\"y\":323.385,\"z\":210.997}',NULL,'[\"apa_v_mp_h_04_a\"]','MiltonDrive',0,1,0,'{\"x\":-766.527,\"y\":327.89,\"z\":210.396}',1300000),
|
||||
(23,'Sharp2Apartment','Appartement Pèrcant 2',NULL,'{\"x\":-786.8663,\"y\":315.764,\"z\":186.913}','{\"x\":-781.808,\"y\":315.866,\"z\":186.913}',NULL,'[\"apa_v_mp_h_04_c\"]','MiltonDrive',0,1,0,'{\"x\":-795.642,\"y\":326.497,\"z\":186.313}',1300000),
|
||||
(24,'Sharp3Apartment','Appartement Pèrcant 3',NULL,'{\"x\":-774.012,\"y\":342.042,\"z\":195.686}','{\"x\":-779.057,\"y\":342.063,\"z\":195.686}',NULL,'[\"apa_v_mp_h_04_b\"]','MiltonDrive',0,1,0,'{\"x\":-765.503,\"y\":331.318,\"z\":195.085}',1300000),
|
||||
(25,'Monochrome1Apartment','Appartement Monochrome 1',NULL,'{\"x\":-784.194,\"y\":323.636,\"z\":210.997}','{\"x\":-779.751,\"y\":323.385,\"z\":210.997}',NULL,'[\"apa_v_mp_h_05_a\"]','MiltonDrive',0,1,0,'{\"x\":-766.289,\"y\":328.086,\"z\":210.396}',1300000),
|
||||
(26,'Monochrome2Apartment','Appartement Monochrome 2',NULL,'{\"x\":-786.8663,\"y\":315.764,\"z\":186.913}','{\"x\":-781.808,\"y\":315.866,\"z\":186.913}',NULL,'[\"apa_v_mp_h_05_c\"]','MiltonDrive',0,1,0,'{\"x\":-795.692,\"y\":326.762,\"z\":186.313}',1300000),
|
||||
(27,'Monochrome3Apartment','Appartement Monochrome 3',NULL,'{\"x\":-774.012,\"y\":342.042,\"z\":195.686}','{\"x\":-779.057,\"y\":342.063,\"z\":195.686}',NULL,'[\"apa_v_mp_h_05_b\"]','MiltonDrive',0,1,0,'{\"x\":-765.094,\"y\":330.976,\"z\":195.085}',1300000),
|
||||
(28,'Seductive1Apartment','Appartement Séduisant 1',NULL,'{\"x\":-784.194,\"y\":323.636,\"z\":210.997}','{\"x\":-779.751,\"y\":323.385,\"z\":210.997}',NULL,'[\"apa_v_mp_h_06_a\"]','MiltonDrive',0,1,0,'{\"x\":-766.263,\"y\":328.104,\"z\":210.396}',1300000),
|
||||
(29,'Seductive2Apartment','Appartement Séduisant 2',NULL,'{\"x\":-786.8663,\"y\":315.764,\"z\":186.913}','{\"x\":-781.808,\"y\":315.866,\"z\":186.913}',NULL,'[\"apa_v_mp_h_06_c\"]','MiltonDrive',0,1,0,'{\"x\":-795.655,\"y\":326.611,\"z\":186.313}',1300000),
|
||||
(30,'Seductive3Apartment','Appartement Séduisant 3',NULL,'{\"x\":-774.012,\"y\":342.042,\"z\":195.686}','{\"x\":-779.057,\"y\":342.063,\"z\":195.686}',NULL,'[\"apa_v_mp_h_06_b\"]','MiltonDrive',0,1,0,'{\"x\":-765.3,\"y\":331.414,\"z\":195.085}',1300000),
|
||||
(31,'Regal1Apartment','Appartement Régal 1',NULL,'{\"x\":-784.194,\"y\":323.636,\"z\":210.997}','{\"x\":-779.751,\"y\":323.385,\"z\":210.997}',NULL,'[\"apa_v_mp_h_07_a\"]','MiltonDrive',0,1,0,'{\"x\":-765.956,\"y\":328.257,\"z\":210.396}',1300000),
|
||||
(32,'Regal2Apartment','Appartement Régal 2',NULL,'{\"x\":-786.8663,\"y\":315.764,\"z\":186.913}','{\"x\":-781.808,\"y\":315.866,\"z\":186.913}',NULL,'[\"apa_v_mp_h_07_c\"]','MiltonDrive',0,1,0,'{\"x\":-795.545,\"y\":326.659,\"z\":186.313}',1300000),
|
||||
(33,'Regal3Apartment','Appartement Régal 3',NULL,'{\"x\":-774.012,\"y\":342.042,\"z\":195.686}','{\"x\":-779.057,\"y\":342.063,\"z\":195.686}',NULL,'[\"apa_v_mp_h_07_b\"]','MiltonDrive',0,1,0,'{\"x\":-765.087,\"y\":331.429,\"z\":195.123}',1300000),
|
||||
(34,'Aqua1Apartment','Appartement Aqua 1',NULL,'{\"x\":-784.194,\"y\":323.636,\"z\":210.997}','{\"x\":-779.751,\"y\":323.385,\"z\":210.997}',NULL,'[\"apa_v_mp_h_08_a\"]','MiltonDrive',0,1,0,'{\"x\":-766.187,\"y\":328.47,\"z\":210.396}',1300000),
|
||||
(35,'Aqua2Apartment','Appartement Aqua 2',NULL,'{\"x\":-786.8663,\"y\":315.764,\"z\":186.913}','{\"x\":-781.808,\"y\":315.866,\"z\":186.913}',NULL,'[\"apa_v_mp_h_08_c\"]','MiltonDrive',0,1,0,'{\"x\":-795.658,\"y\":326.563,\"z\":186.313}',1300000),
|
||||
(36,'Aqua3Apartment','Appartement Aqua 3',NULL,'{\"x\":-774.012,\"y\":342.042,\"z\":195.686}','{\"x\":-779.057,\"y\":342.063,\"z\":195.686}',NULL,'[\"apa_v_mp_h_08_b\"]','MiltonDrive',0,1,0,'{\"x\":-765.287,\"y\":331.084,\"z\":195.086}',1300000),
|
||||
(37,'IntegrityWay','4 Integrity Way','{\"x\":-47.804,\"y\":-585.867,\"z\":36.956}',NULL,NULL,'{\"x\":-54.178,\"y\":-583.762,\"z\":35.798}','[]',NULL,0,0,1,NULL,0),
|
||||
(38,'IntegrityWay28','4 Integrity Way - Apt 28',NULL,'{\"x\":-31.409,\"y\":-594.927,\"z\":79.03}','{\"x\":-26.098,\"y\":-596.909,\"z\":79.03}',NULL,'[]','IntegrityWay',0,1,0,'{\"x\":-11.923,\"y\":-597.083,\"z\":78.43}',1700000),
|
||||
(39,'IntegrityWay30','4 Integrity Way - Apt 30',NULL,'{\"x\":-17.702,\"y\":-588.524,\"z\":89.114}','{\"x\":-16.21,\"y\":-582.569,\"z\":89.114}',NULL,'[]','IntegrityWay',0,1,0,'{\"x\":-26.327,\"y\":-588.384,\"z\":89.123}',1700000),
|
||||
(40,'DellPerroHeights','Dell Perro Heights','{\"x\":-1447.06,\"y\":-538.28,\"z\":33.74}',NULL,NULL,'{\"x\":-1440.022,\"y\":-548.696,\"z\":33.74}','[]',NULL,0,0,1,NULL,0),
|
||||
(41,'DellPerroHeightst4','Dell Perro Heights - Apt 28',NULL,'{\"x\":-1452.125,\"y\":-540.591,\"z\":73.044}','{\"x\":-1455.435,\"y\":-535.79,\"z\":73.044}',NULL,'[]','DellPerroHeights',0,1,0,'{\"x\":-1467.058,\"y\":-527.571,\"z\":72.443}',1700000),
|
||||
(42,'DellPerroHeightst7','Dell Perro Heights - Apt 30',NULL,'{\"x\":-1451.562,\"y\":-523.535,\"z\":55.928}','{\"x\":-1456.02,\"y\":-519.209,\"z\":55.929}',NULL,'[]','DellPerroHeights',0,1,0,'{\"x\":-1457.026,\"y\":-530.219,\"z\":55.937}',1700000)
|
||||
;
|
||||
|
||||
+560
@@ -0,0 +1,560 @@
|
||||
ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
function GetProperty(name)
|
||||
|
||||
for i=1, #Config.Properties, 1 do
|
||||
if Config.Properties[i].name == name then
|
||||
return Config.Properties[i]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function SetPropertyOwned(name, price, rented, owner)
|
||||
|
||||
MySQL.Async.execute(
|
||||
'INSERT INTO owned_properties (name, price, rented, owner) VALUES (@name, @price, @rented, @owner)',
|
||||
{
|
||||
['@name'] = name,
|
||||
['@price'] = price,
|
||||
['@rented'] = (rented and 1 or 0),
|
||||
['@owner'] = owner
|
||||
},
|
||||
function(rowsChanged)
|
||||
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
|
||||
for k,v in pairs(xPlayers) do
|
||||
if v.identifier == owner then
|
||||
|
||||
TriggerClientEvent('esx_property:setPropertyOwned', v.source, name, true)
|
||||
|
||||
if rented then
|
||||
TriggerClientEvent('esx:showNotification', v.source, 'Vous avez loué une propriété pour $' .. price)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', v.source, 'Vous avez acheté une propriété pour $' .. price)
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
function RemoveOwnedProperty(name, owner)
|
||||
|
||||
MySQL.Async.execute(
|
||||
'DELETE FROM owned_properties WHERE name = @name AND owner = @owner',
|
||||
{
|
||||
['@name'] = name,
|
||||
['@owner'] = owner
|
||||
},
|
||||
function(rowsChanged)
|
||||
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
|
||||
for k,v in pairs(xPlayers) do
|
||||
if v.identifier == owner then
|
||||
TriggerClientEvent('esx_property:setPropertyOwned', v.source, name, false)
|
||||
TriggerClientEvent('esx:showNotification', v.source, 'Vous avez rendu une propriété')
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
AddEventHandler('onMySQLReady', function ()
|
||||
|
||||
MySQL.Async.fetchAll('SELECT * FROM properties', {}, function(properties)
|
||||
|
||||
for i=1, #properties, 1 do
|
||||
|
||||
local entering = nil
|
||||
local exit = nil
|
||||
local inside = nil
|
||||
local outside = nil
|
||||
local isSingle = nil
|
||||
local isRoom = nil
|
||||
local isGateway = nil
|
||||
local roomMenu = nil
|
||||
|
||||
if properties[i].entering ~= nil then
|
||||
entering = json.decode(properties[i].entering)
|
||||
end
|
||||
|
||||
if properties[i].exit ~= nil then
|
||||
exit = json.decode(properties[i].exit)
|
||||
end
|
||||
|
||||
if properties[i].inside ~= nil then
|
||||
inside = json.decode(properties[i].inside)
|
||||
end
|
||||
|
||||
if properties[i].outside ~= nil then
|
||||
outside = json.decode(properties[i].outside)
|
||||
end
|
||||
|
||||
if properties[i].is_single == 0 then
|
||||
isSingle = false
|
||||
else
|
||||
isSingle = true
|
||||
end
|
||||
|
||||
if properties[i].is_room == 0 then
|
||||
isRoom = false
|
||||
else
|
||||
isRoom = true
|
||||
end
|
||||
|
||||
if properties[i].is_gateway == 0 then
|
||||
isGateway = false
|
||||
else
|
||||
isGateway = true
|
||||
end
|
||||
|
||||
if properties[i].room_menu ~= nil then
|
||||
roomMenu = json.decode(properties[i].room_menu)
|
||||
end
|
||||
|
||||
table.insert(Config.Properties, {
|
||||
name = properties[i].name,
|
||||
label = properties[i].label,
|
||||
entering = entering,
|
||||
exit = exit,
|
||||
inside = inside,
|
||||
outside = outside,
|
||||
ipls = json.decode(properties[i].ipls),
|
||||
gateway = properties[i].gateway,
|
||||
isSingle = isSingle,
|
||||
isRoom = isRoom,
|
||||
isGateway = isGateway,
|
||||
roomMenu = roomMenu,
|
||||
price = properties[i].price
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_ownedproperty:getOwnedProperties', function(cb)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_properties',
|
||||
{},
|
||||
function(result)
|
||||
|
||||
local properties = {}
|
||||
|
||||
for i=1, #result, 1 do
|
||||
|
||||
table.insert(properties, {
|
||||
id = result[i].id,
|
||||
name = result[i].name,
|
||||
price = result[i].price,
|
||||
rented = (rented == 1 and true or false),
|
||||
owner = result[i].owner,
|
||||
})
|
||||
end
|
||||
|
||||
cb(properties)
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_property:setPropertyOwned', function(name, price, rented, owner)
|
||||
SetPropertyOwned(name, price, rented, owner)
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_property:removeOwnedProperty', function(name, owner)
|
||||
RemoveOwnedProperty(name, owner)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:rentProperty')
|
||||
AddEventHandler('esx_property:rentProperty', function(propertyName)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local property = GetProperty(propertyName)
|
||||
|
||||
SetPropertyOwned(propertyName, property.price / 200, true, xPlayer.identifier)
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:buyProperty')
|
||||
AddEventHandler('esx_property:buyProperty', function(propertyName)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local property = GetProperty(propertyName)
|
||||
|
||||
if property.price <= xPlayer.get('money') then
|
||||
|
||||
xPlayer.removeMoney(property.price)
|
||||
SetPropertyOwned(propertyName, property.price, false, xPlayer.identifier)
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, 'Vous n\'avez pas assez d\'argent')
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:removeOwnedProperty')
|
||||
AddEventHandler('esx_property:removeOwnedProperty', function(propertyName)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
RemoveOwnedProperty(propertyName, xPlayer.identifier)
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_property:removeOwnedPropertyIdentifier', function(propertyName, identifier)
|
||||
RemoveOwnedProperty(propertyName, identifier)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:saveLastProperty')
|
||||
AddEventHandler('esx_property:saveLastProperty', function(property)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
MySQL.Async.execute(
|
||||
'UPDATE users SET last_property = @last_property WHERE identifier = @identifier',
|
||||
{
|
||||
['@last_property'] = property,
|
||||
['@identifier'] = xPlayer.identifier
|
||||
}
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:deleteLastProperty')
|
||||
AddEventHandler('esx_property:deleteLastProperty', function()
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
MySQL.Async.execute(
|
||||
'UPDATE users SET last_property = NULL WHERE identifier = @identifier',
|
||||
{
|
||||
['@identifier'] = xPlayer.identifier
|
||||
}
|
||||
)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:getItem')
|
||||
AddEventHandler('esx_property:getItem', function(type, item, count)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
if type == 'item_standard' then
|
||||
|
||||
TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayer.identifier, function(inventory)
|
||||
|
||||
local roomItemCount = inventory.getItem(item).count
|
||||
|
||||
if roomItemCount >= count then
|
||||
inventory.removeItem(item, count)
|
||||
xPlayer.addInventoryItem(item, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, 'Quantité invalide')
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
if type == 'item_account' then
|
||||
|
||||
TriggerEvent('esx_addonaccount:getAccount', 'property_' .. item, xPlayer.identifier, function(account)
|
||||
|
||||
local roomAccountMoney = account.money
|
||||
|
||||
if roomAccountMoney >= count then
|
||||
account.removeMoney(count)
|
||||
xPlayer.addAccountMoney(item, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, 'Montant invalide')
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
if type == 'item_weapon' then
|
||||
|
||||
TriggerEvent('esx_datastore:getDataStore', 'property', xPlayer.identifier, function(store)
|
||||
|
||||
local storeWeapons = store.get('weapons')
|
||||
|
||||
if storeWeapons == nil then
|
||||
storeWeapons = {}
|
||||
end
|
||||
|
||||
local weaponName = nil
|
||||
local ammo = nil
|
||||
|
||||
for i=1, #storeWeapons, 1 do
|
||||
if storeWeapons[i].name == item then
|
||||
|
||||
weaponName = storeWeapons[i].name
|
||||
ammo = storeWeapons[i].ammo
|
||||
|
||||
table.remove(storeWeapons, i)
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
store.set('weapons', storeWeapons)
|
||||
|
||||
xPlayer.addWeapon(weaponName, ammo)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_property:putItem')
|
||||
AddEventHandler('esx_property:putItem', function(type, item, count)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
if type == 'item_standard' then
|
||||
|
||||
local playerItemCount = xPlayer.getInventoryItem(item).count
|
||||
|
||||
if playerItemCount >= count then
|
||||
|
||||
xPlayer.removeInventoryItem(item, count)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayer.identifier, function(inventory)
|
||||
inventory.addItem(item, count)
|
||||
end)
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, 'Quantité invalide')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if type == 'item_account' then
|
||||
|
||||
local playerAccountMoney = xPlayer.getAccount(item).money
|
||||
|
||||
if playerAccountMoney >= count then
|
||||
|
||||
xPlayer.removeAccountMoney(item, count)
|
||||
|
||||
TriggerEvent('esx_addonaccount:getAccount', 'property_' .. item, xPlayer.identifier, function(account)
|
||||
account.addMoney(count)
|
||||
end)
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, 'Montant invalide')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if type == 'item_weapon' then
|
||||
|
||||
TriggerEvent('esx_datastore:getDataStore', 'property', xPlayer.identifier, function(store)
|
||||
|
||||
local storeWeapons = store.get('weapons')
|
||||
|
||||
if storeWeapons == nil then
|
||||
storeWeapons = {}
|
||||
end
|
||||
|
||||
table.insert(storeWeapons, {
|
||||
name = item,
|
||||
ammo = count
|
||||
})
|
||||
|
||||
store.set('weapons', storeWeapons)
|
||||
|
||||
xPlayer.removeWeapon(item)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:getProperties', function(source, cb)
|
||||
cb(Config.Properties)
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:getOwnedProperties', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_properties WHERE owner = @owner',
|
||||
{
|
||||
['@owner'] = xPlayer.identifier
|
||||
},
|
||||
function(ownedProperties)
|
||||
|
||||
local properties = {}
|
||||
|
||||
for i=1, #ownedProperties, 1 do
|
||||
table.insert(properties, ownedProperties[i].name)
|
||||
end
|
||||
|
||||
cb(properties)
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:getLastProperty', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM users WHERE identifier = @identifier',
|
||||
{
|
||||
['@identifier'] = xPlayer.identifier
|
||||
},
|
||||
function(users)
|
||||
cb(users[1].last_property)
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:getPropertyInventory', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local blackMoney = 0
|
||||
local items = {}
|
||||
local weapons = {}
|
||||
|
||||
TriggerEvent('esx_addonaccount:getAccount', 'property_black_money', xPlayer.identifier, function(account)
|
||||
blackMoney = account.money
|
||||
end)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayer.identifier, function(inventory)
|
||||
items = inventory.items
|
||||
end)
|
||||
|
||||
TriggerEvent('esx_datastore:getDataStore', 'property', xPlayer.identifier, function(store)
|
||||
|
||||
local storeWeapons = store.get('weapons')
|
||||
|
||||
if storeWeapons ~= nil then
|
||||
weapons = storeWeapons
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
cb({
|
||||
blackMoney = blackMoney,
|
||||
items = items,
|
||||
weapons = weapons
|
||||
})
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:getPlayerInventory', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local blackMoney = xPlayer.getAccount('black_money').money
|
||||
local items = xPlayer.inventory
|
||||
|
||||
cb({
|
||||
blackMoney = blackMoney,
|
||||
items = items
|
||||
})
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:getPlayerDressing', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local dressing = {}
|
||||
|
||||
TriggerEvent('esx_datastore:getDataStore', 'property', xPlayer.identifier, function(store)
|
||||
|
||||
local storeDressing = store.get('dressing')
|
||||
|
||||
if storeDressing ~= nil then
|
||||
dressing = storeDressing
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
cb(dressing)
|
||||
|
||||
end)
|
||||
|
||||
function PayRent(d, h, m)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_properties WHERE rented = 1',
|
||||
{},
|
||||
function(result)
|
||||
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
|
||||
for i=1, #result, 1 do
|
||||
|
||||
local foundPlayer = false
|
||||
local xPlayer = nil
|
||||
|
||||
for k,v in pairs(xPlayers) do
|
||||
if v.identifier == result[i].owner then
|
||||
foundPlayer = true
|
||||
xPlayer = v
|
||||
end
|
||||
end
|
||||
|
||||
if foundPlayer then
|
||||
|
||||
xPlayer.removeMoney(result[i].price)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, 'Vous avez ~g~payé~s~ votre loyer : ~g~$' .. result[i].price)
|
||||
|
||||
else
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM users WHERE identifier = @identifier',
|
||||
{
|
||||
['@identifier'] = result[i].owner
|
||||
},
|
||||
function(result2)
|
||||
|
||||
local money = result2[1].money
|
||||
money = money - result[i].price
|
||||
|
||||
MySQL.Async.execute(
|
||||
'UPDATE users SET money = @money WHERE identifier = @identifier',
|
||||
{
|
||||
['@money'] = money,
|
||||
['@identifier'] = result[i].owner
|
||||
}
|
||||
)
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account)
|
||||
account.addMoney(result[i].price)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
TriggerEvent('cron:runAt', 22, 0, PayRent)
|
||||
Reference in New Issue
Block a user