Skip to content

Commit

Permalink
Logs Added (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
complexza authored Jul 31, 2023
1 parent 3ea128a commit c608309
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,17 @@ end)

10. Install the dependencies below.

## Logs System Setup

1. Go to `qb-smallresources/server/logs.lua` and add this:
```lua
['pshousing'] = 'yourdiscordwebhookhere',
```
2. Create a webhook for the channel you want the logs to show up in.
3. Replace the placeholder with your webhook link.

> This system only supports qb-core for now.
# Dependency
1. [bl-realtor](https://github.com/Byte-Labs-Project/bl-realtor)
2. [five-freecam](https://github.com/Deltanic/fivem-freecam)
Expand Down
3 changes: 3 additions & 0 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ RegisterNetEvent("ps-housing:server:createNewApartment", function(aptLabel)
}

Debug("Creating new apartment for " .. GetPlayerName(src) .. " in " .. apartment.label)

Framework[Config.Logs].SendLog("Creating new apartment for " .. GetPlayerName(src) .. " in " .. apartment.label)

TriggerEvent("ps-housing:server:registerProperty", propertyData)
end)

Expand Down
27 changes: 25 additions & 2 deletions server/sv_property.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ function Property:UpdateDescription(data)

TriggerClientEvent("ps-housing:client:updateProperty", -1, "UpdateDescription", self.property_id, description)

Framework[Config.Logs].SendLog("**Changed Description** of property with id: " .. self.property_id .. " by: " .. GetPlayerName(realtorSrc))

Debug("Changed Description of property with id: " .. self.property_id, "by: " .. GetPlayerName(realtorSrc))
end

Expand All @@ -181,6 +183,8 @@ function Property:UpdatePrice(data)

TriggerClientEvent("ps-housing:client:updateProperty", -1, "UpdatePrice", self.property_id, price)

Framework[Config.Logs].SendLog("**Changed Price** of property with id: " .. self.property_id .. " by: " .. GetPlayerName(realtorSrc))

Debug("Changed Price of property with id: " .. self.property_id, "by: " .. GetPlayerName(realtorSrc))
end

Expand All @@ -197,6 +201,8 @@ function Property:UpdateForSale(data)

TriggerClientEvent("ps-housing:client:updateProperty", -1, "UpdateForSale", self.property_id, forsale)

Framework[Config.Logs].SendLog("**Changed For Sale** of property with id: " .. self.property_id .. " by: " .. GetPlayerName(realtorSrc))

Debug("Changed For Sale of property with id: " .. self.property_id, "by: " .. GetPlayerName(realtorSrc))
end

Expand All @@ -215,6 +221,8 @@ function Property:UpdateShell(data)

TriggerClientEvent("ps-housing:client:updateProperty", -1, "UpdateShell", self.property_id, shell)

Framework[Config.Logs].SendLog("**Changed Shell** of property with id: " .. self.property_id .. " by: " .. GetPlayerName(realtorSrc))

Debug("Changed Shell of property with id: " .. self.property_id, "by: " .. GetPlayerName(realtorSrc))
end

Expand Down Expand Up @@ -288,6 +296,8 @@ function Property:UpdateOwner(data)

TriggerClientEvent("ps-housing:client:updateProperty", -1, "UpdateOwner", self.property_id, citizenid)

Framework[Config.Logs].SendLog("**House Bought** by: **"..PlayerData.charinfo.firstname.." "..PlayerData.charinfo.lastname.."** for $"..self.propertyData.price.." from **"..realtor.PlayerData.charinfo.firstname.." "..realtor.PlayerData.charinfo.lastname.."** !")

Framework[Config.Notify].Notify(targetSrc, "You have bought the property for $"..self.propertyData.price, "success")
Framework[Config.Notify].Notify(realtorSrc, "Client has bought the property for $"..self.propertyData.price, "success")
end
Expand All @@ -305,6 +315,8 @@ function Property:UpdateImgs(data)

TriggerClientEvent("ps-housing:client:updateProperty", -1, "UpdateImgs", self.property_id, imgs)

Framework[Config.Logs].SendLog("**Changed Images** of property with id: " .. self.property_id .. " by: " .. GetPlayerName(realtorSrc))

Debug("Changed Imgs of property with id: " .. self.property_id, "by: " .. GetPlayerName(realtorSrc))
end

Expand Down Expand Up @@ -340,6 +352,8 @@ function Property:UpdateDoor(data)

TriggerClientEvent("ps-housing:client:updateProperty", -1, "UpdateDoor", self.property_id, newDoor, data.street, data.region)

Framework[Config.Logs].SendLog("**Changed Door** of property with id: " .. self.property_id .. " by: " .. GetPlayerName(realtorSrc))

Debug("Changed Door of property with id: " .. self.property_id, "by: " .. GetPlayerName(realtorSrc))
end

Expand Down Expand Up @@ -384,6 +398,8 @@ function Property:UpdateGarage(data)

TriggerClientEvent("ps-housing:client:updateProperty", -1, "UpdateGarage", self.property_id, garage)

Framework[Config.Logs].SendLog("**Changed Garage** of property with id: " .. self.property_id .. " by: " .. GetPlayerName(realtorSrc))

Debug("Changed Garage of property with id: " .. self.property_id, "by: " .. GetPlayerName(realtorSrc))
end

Expand All @@ -400,9 +416,11 @@ function Property:UpdateApartment(data)
})

Framework[Config.Notify].Notify(realtorSrc, "Changed Apartment of property with id: " .. self.property_id .." to ".. apartment, "success")

Framework[Config.Notify].Notify(targetSrc, "Changed Apartment to " .. apartment, "success")

Framework[Config.Logs].SendLog("**Changed Apartment** with id: " .. self.property_id .. " by: **" .. GetPlayerName(realtorSrc) .. "** for **" .. GetPlayerName(targetSrc) .."**")

TriggerClientEvent("ps-housing:client:updateProperty", -1, "UpdateApartment", self.property_id, apartment)

Debug("Changed Apartment of property with id: " .. self.property_id, "by: " .. GetPlayerName(realtorSrc))
Expand All @@ -422,7 +440,9 @@ function Property:DeleteProperty(data)
TriggerClientEvent("ps-housing:client:removeProperty", -1, self.property_id)

Framework[Config.Notify].Notify(realtorSrc, "Property with id: " .. self.property_id .." has been removed.", "info")


Framework[Config.Logs].SendLog("**Property Deleted** with id: " .. self.property_id .. " by: " .. GetPlayerName(realtorSrc))

Debug("Deleted property with id: " .. self.property_id, "by: " .. GetPlayerName(realtorSrc))
PropertiesTable[self.property_id] = nil
self = nil
Expand Down Expand Up @@ -608,6 +628,9 @@ RegisterNetEvent("ps-housing:server:buyFurniture", function(property_id, items,
property:UpdateFurnitures(property.propertyData.furnitures)

Framework[Config.Notify].Notify(src, "You bought furniture for $" .. price, "success")

Framework[Config.Logs].SendLog("**Player ".. GetPlayerName(src) .. "** bought furniture for **$" .. price"**")

Debug("Player bought furniture for $" .. price, "by: " .. GetPlayerName(src))
end)

Expand Down
4 changes: 4 additions & 0 deletions shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Config.Target = "ox" -- "ox" or "qb"
Config.Notify = "ox" -- "ox" or "qb"
Config.Radial = "ox" -- "ox" or "qb"
Config.Inventory = "qb" -- "ox" or "qb"
Config.Logs = "qb" -- "qb"

-- Anyone provided with keys to a property has the ability to modify its furnishings.
Config.AccessCanEditFurniture = true
Expand All @@ -24,6 +25,9 @@ function Debug(...)
end
end

-- Log System
Config.EnableLogs = true

-- Enables Dynamic Doors
Config.DynamicDoors = false

Expand Down
10 changes: 10 additions & 0 deletions shared/framework.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ if IsDuplicityVersion() then
-- Used for ox_inventory compat
end

function Framework.qb.SendLog(message)
if Config.EnableLogs then
TriggerEvent('qb-log:server:CreateLog', 'pshousing', 'Housing System', 'blue', message)
end
end

function Framework.ox.SendLog(message)
-- noop
end

return
end

Expand Down

0 comments on commit c608309

Please sign in to comment.