Overview
This prompt aims to guide developers in creating a FiveM script for monitoring player activity and preventing AFK kicks. Programmers working on multiplayer gaming servers will benefit from this structured approach to enhance player engagement.
Prompt Overview
Purpose: This script monitors player activity to prevent unwanted kicks due to inactivity.
Audience: It is designed for FiveM server administrators and developers looking to enhance player experience.
Distinctive Feature: The script features a user interface that prompts for code entry when a player is detected as AFK.
Outcome: Players can avoid being kicked by entering a verification code, ensuring a smoother gaming experience.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Banking (Retail & Commercial), Content & Media Creation, Development Tools & DevOps
- Techniques: Few-Shot Prompting, Plan-Then-Solve, Structured Output
- Models: Claude 3.5 Sonnet, Gemini 2.0 Flash, GPT-4o, Llama 3.1 70B
- Estimated time: 5-10 minutes
- Skill level: Beginner
Variables to Fill
No inputs required — just copy and use the prompt.
Example Variables Block
No example values needed for this prompt.
The Prompt
Create a FiveM script that monitors player activity for a duration of 1 minute. If a player is detected as AFK (Away From Keyboard), a user interface (UI) should pop up prompting the player to enter a code. If the player successfully enters the correct code, they will not be kicked from the server.
**Requirements:**
– Track player inactivity by checking input (e.g., keyboard, mouse) every few seconds.
– If no input is detected for 1 minute, trigger the UI to appear, asking for code entry.
– Provide a configurable way to set:
– AFK timeout duration
– Verification code
– Define behavior for:
– Correct code entry
– Incorrect code entry (allow three attempts before kicking the player)
– Implement clean UI elements that visually integrate with the existing game interface.
– Document the script with comments explaining each function’s purpose and usage.
**Output Format:**
A complete Lua script for FiveM, including functions for:
– Detecting player activity
– Displaying the UI
– Handling code verification
Ensure the script adheres to best practices for performance and readability.
**Examples:**
– When the player is inactive for 60 seconds, the UI should show:
– ‘You are AFK, enter the code to prevent a kick.’
– If the player enters the correct code, e.g., ‘1234’, a message should display:
– ‘Code accepted, you will not be kicked.’
– If they enter an incorrect code, e.g., ‘4321’, a message should be:
– ‘Incorrect code, you have 2 attempts remaining.’
**Notes:**
– Consider potential edge cases, such as:
– What happens if the player quickly re-enters inputs immediately after being marked AFK.
– Include a way to reset the AFK timer if the player interacts with the game before the kick occurs.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Open your preferred code editor for Lua scripting.
- Create a new Lua file for the FiveM script.
- Paste the copied prompt into the file for reference.
- Follow the requirements to write the script.
- Test the script in your FiveM server environment.
Tips for Best Results
- Track Player Activity: Use a timer to monitor input events like keyboard and mouse activity every few seconds to determine if the player is AFK.
- Display AFK UI: After 1 minute of inactivity, trigger a UI prompt asking the player to enter a verification code to avoid being kicked.
- Handle Code Verification: Allow three attempts for the player to enter the correct code; provide feedback on success or failure after each attempt.
- Reset AFK Timer: Implement a mechanism to reset the AFK timer if any input is detected before the kick occurs, ensuring active players are not penalized.
FAQ
- How do I track player inactivity in FiveM?
You can track player inactivity by monitoring keyboard and mouse inputs every few seconds. - What happens after 1 minute of inactivity?
After 1 minute, a UI prompts the player to enter a verification code. - What if the player enters the correct code?
If the correct code is entered, a message confirms they won't be kicked from the server. - What occurs after three incorrect code attempts?
After three incorrect attempts, the player will be kicked from the server.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


