first, sorry for my poor english, im not native in english. I want to create a plugin like devided players into groups without esx, first todo is to get the player
s identifier, such license: or steam: etc. and I have problem on getting it.
function GetPlayerIdentifier
is a server function. so I should let client send request to server and server return it.
my code is like this
client.lua
--获取玩家ped,id,用于和服务端通信
--get player ped to communicate with server
local ped = GetPlayerPed(-1)
local id = GetPlayerServerId(-1);
print('ped' .. ped.. 'id'..id)
--要求服务端传回玩家标识符
--ask server for player identifiers
RegisterCommand('identifier', function()
TriggerServerEvent('getplayeridentifier', id )
end,false)
--接受服务端传回的标识符
--receive the identifier from server
RegisterNetEvent('receiveidentifier')
AddEventHandler('receiveidentifier', function (license)
license = license;
print('license'..license)
end)
server.lua
local steamid = false
local license = false
local discord = false
local xbl = false
local liveid = false
local ip = false
--接受客户端标识符的命令,产生标识符
--receive the command from the client and get identifiers
RegisterServerEvent('getplayeridentifier');
AddEventHandler('getplayeridentifier', function(id)
id = id;
for k,v in pairs(GetPlayerIdentifiers(source))do
if string.sub(v, 1, string.len("steam:")) == "steam:" then
steamid = v
elseif string.sub(v, 1, string.len("license:")) == "license:" then
license = v
elseif string.sub(v, 1, string.len("xbl:")) == "xbl:" then
xbl = v
elseif string.sub(v, 1, string.len("ip:")) == "ip:" then
ip = v
elseif string.sub(v, 1, string.len("discord:")) == "discord:" then
discord = v
elseif string.sub(v, 1, string.len("live:")) == "live:" then
liveid = v
end
end
--将玩家标识符传回客户端
--send the player identifiers to the client
TriggerClientEvent('receiveidentifier', id, license)
end)
and when I ensure this plugin and type command /identifier, client do not return anything.
and when I add print() on the server.lua, the console do not return anything either.
I do not know what the problem is, I am looking for help!