Triggers
Available Triggers
Paycheck All
This trigger will be used to charge all users who have a rented room:
TriggerClientEvent("bit-motels:paycheckAll")
Usage: Call this trigger to process rent payments for all players with rented rooms. Useful for scheduled payment systems or automatic weekly rent collection.
Example Integration:
-- In your scheduling system
CreateThread(function()
while true do
Wait(604800000) -- Wait 1 week (in milliseconds)
TriggerClientEvent("bit-motels:paycheckAll", -1)
end
end)
Paycheck User
This trigger will be used to charge a specific user who has a rented room:
TriggerClientEvent("bit-motels:paycheckUser", playerID)
Parameters:
playerID: The server ID of the player to charge
Usage: Call this trigger to process rent payment for a specific player. Useful for manual rent collection or event-based payment systems.
Example Integration:
-- Charge a specific player
local playerId = 1
TriggerClientEvent("bit-motels:paycheckUser", playerId)
Payment System Configuration
Configure the payment system in config.lua:
-- Automatic payments at specific time
Config.usePayHour = false
Config.rentPayHour = 22 -- 10 PM (24-hour format)
Payment Time Options
If Config.usePayHour = true:
- Rent will be charged automatically at the time specified in
Config.rentPayHour - Time is in 24-hour format (0-23)
- Example:
22= 10:00 PM server time
If Config.usePayHour = false:
- Use the triggers above to manually control payment timing
- Integrate with your own scheduling system
- More flexibility for custom payment schedules
Server Functions Integration
Billing Script Integration
If you want to use an external billing system:
- Set
Config.useBillingScript = truein config - Open
s_functions.lua - Navigate to line 53
- Modify the billing function to integrate with your system:
-- Line 53 in s_functions.lua
function sendBill(playerId, amount)
-- Replace with your billing system
-- Example: TriggerEvent('esx_billing:sendBill', playerId, 'motel', 'Motel Rent', amount)
end
Mobile Notification Integration
If you want to send phone notifications when rent is due:
- Set
Config.useMobileNotification = truein config - Open
s_functions.lua - Navigate to line 58
- Modify the notification function:
-- Line 58 in s_functions.lua
function sendPhoneNotification(playerId, message)
-- Replace with your phone system
-- Example: TriggerClientEvent('phone:notification', playerId, {title = 'Motel', message = message})
end
Troubleshooting
Issue: Payments not processing
Possible Causes:
- Player not online when trigger fires
- Insufficient funds in player account
- Database connection issues
Solutions:
- Check server console for errors
- Verify player has enough money
- Ensure database is properly configured
- Check
Config.Mysqlsetting matches your SQL resource
Issue: All players charged instead of one
Cause: Using paycheckAll trigger when intending to charge specific player
Solution: Use paycheckUser with correct playerID parameter
Issue: Rent charged at wrong time
Cause: Server timezone differs from expected timezone
Solution: Adjust Config.rentPayHour to match your server's timezone or use manual triggers
Issue: Owners not receiving income
Possible Causes:
Config.costspercentagemisconfigured- Database table
bit_motels_ownersnot updated - Room not properly rented in database
Solutions:
- Verify
Config.costspercentage = 0.55(55% to owner) - Check
bit_motels_ownerstable for correct owner entry - Confirm room rental exists in
bit_motelstable - Restart script after database changes