你好,我正在开发一个机器人为fivem在javascript语言,但我不知道如何检测球员的id为人民谁加入服务器,请能帮助这是我的代码
on('playerConnecting', async(name, setKickReason, deferrals) => {
const chann = client.channels.cache.get("room id")
const guild = client.guilds.cache.get("serverid");
deferrals.defer()
deferrals.update("message")
const player = global.source;
let discord = "**undefined**";
let steam = "**undefined**";
let fivem = "**undefined**";
let ip = "**undefined**";
let license = "**undefined**";
for (let i = 0; i < GetNumPlayerIdentifiers(player); i++) {
const identifier = GetPlayerIdentifier(player, i);
if (identifier.includes('discord:')) {
discord = identifier
} else if(identifier.includes('steam:')) {
steam = identifier
} else if(identifier.includes('fivem:')) {
fivem = identifier
} else if(identifier.includes("ip:")) {
ip = identifier;
}else if(identifier.includes("license:")) {
license = identifier;
}
}
setTimeout(async() => {
discord = discord.split('discord:').pop()
steam = steam.split('steam:').pop()
ip = ip.split('ip:').pop()
license = license.split('license:').pop()
fivem = fivem.split('fivem:').pop()
let pingg = GetPlayerPing(player)
let embed= new MessageEmbed()
.setColor("RED")
.addField(`**Default Name**`,`**${name}**`)
.addField(`**Steam Name**`,`**${steam}**`)
.addField(`**FiveM Name**`,`**${fivem}**`)
.addField(`**Discord Name**`,`<@${discord}>`)
.addField(`**Discord id**`,`**${discord}**`)
.addField(`**IP**`,`**${ip}**`)
.addField(`**License**`,`**${license}**`)
.addField(`**Ping**`,`**${pingg}**`)
.addField(`**player-id**`,`**${player.id}**`)
.setFooter(guild.name)
.setTimestamp()
let mes = await chann.send(embed)
我尝试将[player.id]放入字段中,但没有成功
1条答案
按热度按时间i5desfxk1#
本地命令Map到全局JavaScript函数,其名称类似于Lua本地Mapper FiveM native docs
因此,您应该能够像使用其他原生代码(
GetPlayerPing
、GetPlayerIdentifier
等)一样使用原生代码GetPlayerServerId
。您可以在documentation中看到JS和Lua的所有原生代码。