Skip to content

Andrada Legal Welcome Screen

thefourCraft edited this page Dec 6, 2022 · 3 revisions

image

About

This script is a server-side script that is used to implement a custom player connection process in a FiveM server.

When a player attempts to connect to the server, the playerConnecting event is triggered, and the script registers an event handler function to handle the event. The event handler function receives the player's name, a function to set the kick reason and a deferrals object as its arguments.

The script then uses the GetNumPlayerIndices() function to get the number of players currently connected to the server, and the GetConvarInt() function to get the maximum number of players allowed on the server.

Next, the script updates the deferrals message using the deferrals.update() function, and creates an adaptive card using the card variable. The adaptive card contains a message that welcomes the player and displays the current number of players on the server and asks the player if they want to connect to the server. The adaptive card also contains two action buttons: one to confirm the player's decision, and another to cancel the connection.

The script then defines a CheckChoice() function, which is called when the player clicks one of the action buttons in the adaptive card. This function checks the data received from the adaptive card to see if the player clicked the "Yes" or "No" button, and takes appropriate action based on the player's response. If the player clicked the "Yes" button, the function checks if the server is full, and either sets the kick reason or allows the player to connect. If the player clicked the "No" button, the function sets the kick reason to inform the player that they chose not to connect.

Finally, the script uses the deferrals.presentCard() function to present the adaptive card to the player and register the CheckChoice() function as the callback for the card. This allows the script to process the player's response and take appropriate action.


How To Install

Clone this wiki locally