πŸ”₯All scripts on our website are 50% off!πŸ”₯
Logo

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:

  1. Set Config.useBillingScript = true in config
  2. Open s_functions.lua
  3. Navigate to line 53
  4. 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:

  1. Set Config.useMobileNotification = true in config
  2. Open s_functions.lua
  3. Navigate to line 58
  4. 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:

  1. Check server console for errors
  2. Verify player has enough money
  3. Ensure database is properly configured
  4. Check Config.Mysql setting 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.costspercentage misconfigured
  • Database table bit_motels_owners not updated
  • Room not properly rented in database

Solutions:

  1. Verify Config.costspercentage = 0.55 (55% to owner)
  2. Check bit_motels_owners table for correct owner entry
  3. Confirm room rental exists in bit_motels table
  4. Restart script after database changes