Server-Side Town Supplies

The server-side code for managing town supplies is responsible for interacting with the database, fetching town data, and handling requests from clients. This allows town supplies to be adjusted, updated, and broadcasted to all connected clients. Below is the full breakdown, examples, and guidelines for developers using the server-side functionality.

πŸ“ Correct Usage for Developers

To use the server-side functionality correctly, follow these key steps:

  1. Triggering Events:

    • Ensure you are calling the correct event for fetching town supplies:

      TriggerServerEvent('codex-studios-supplies:city_supplies')
    • You can fetch town supplies via the event codex-studios-supplies:city_supplies_refetch to refresh the data at any point:

      TriggerServerEvent('codex-studios-supplies:city_supplies_refetch')
  2. Removing Supplies:

    • To remove supplies from a town (e.g., after an event like a raid):

      TriggerServerEvent('codex-studios-supplies:city_removesupplies', "town_name")
  3. Resupplying a Town:

    • Use the resupply event when a town needs to be resupplied:

      TriggerServerEvent('codex-studios-supplies:city_resupplies', "town_name") 

🚫 Incorrect Usage Examples

  1. Missing Town Parameter:

    • If you fail to provide the town parameter, the function will return an error:

      TriggerEvent('codex-studios-supplies:city_removesupplies', nil) -- This will not work
  2. Using Incorrect Event Names:

    • Calling events with wrong names will fail:

      TriggerEvent('wrong_event_name') -- This will not trigger the correct function

Last updated

Was this helpful?