Hi! I am currently making a script where you can apply for police in game, but do anyone know how I could get the person that is using my menu to get there discord name?
Well what UI are you using?
I am currently using NUI
get their discord identifiers then grab their discord UID then transform that into a name pretty simple
With TriggerServerEvent
, send the player server id (GetPlayerServerId(PlayerId())
) to the server side. There you should check if the player has a discord identifier using this method. Then with the use of Discord API, you should call this endpoint. If you don’t know how to do it, here is an example. At last, using TriggerClientEvent
, you can send back the name, and use it in your menu.
Firstly you’ll need their Discord ID, which you can obtain through the GetPlayerIdentifier native.
Then you can use Discord’s API to fetch their discord username, using their ID. You may need to setup a bot within your server to do this, however I’m not too sure on that.
Well use methods above this and you can pretty much just display there discord name to make sure they’re wanting to apply with such name or manual input it instead.