-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhousingData_c.lua
55 lines (49 loc) · 1.63 KB
/
housingData_c.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-- Congratulations, you got rid of this shit
--[[
-- Change this variable sometime to not cause confustion with the houseData table
housingData = {}
-- We shouldn't sync the whole table, maybe just the new additions? I dunno.
function syncHousingTable(sync)
housingData = sync
end
addEvent("UCDhousing.syncHousingTable", true)
addEventHandler("UCDhousing.syncHousingTable", root, syncHousingTable)
function syncHouse(houseID, houseTable)
if (not houseID) or (not houseTable) then
return
end
housingData[houseID] = houseTable
outputDebugString("Synced housing data for houseID = "..houseID)
end
addEvent("UCDhousing.syncHouse", true)
addEventHandler("UCDhousing.syncHouse", root, syncHouse)
-- I didn't want to request the data on resource start, but we'll need a login event of some sort (client-side)
-- This is only for if the resource is restarted
function requestHousingTableSync()
if (exports.UCDaccounts:isPlayerLoggedIn(localPlayer)) then
setTimer(
function ()
triggerServerEvent("UCDhousing.requestHousingTableSync", localPlayer)
end, 500, 1, localPlayer
)
end
end
addEventHandler("onClientResourceStart", resourceRoot, requestHousingTableSync)
function getHouseData(houseID, column)
if (not houseID) or (not column) then
return nil
end
if (type(column) ~= "string") or (type(houseID) ~= "number") then
return false
end
if (column == "*") then
return housingData[houseID]
else
if (housingData[houseID] == nil) or (housingData[houseID][column] == nil) then
return nil
end
end
outputDebugString("Client call for getHouseData. Column: "..column.." houseID: "..houseID)
return housingData[houseID][column]
end
--]]