DoesIdExist
Checking player Id for that does it exist
Last updated
Checking player Id for that does it exist
Last updated
Parameter | Type | Description | Required |
---|---|---|---|
RETURN: boolean
Example:
HRLib = exports.HRLib:getLibFunctions() -- Getting HRLib client or server functions list
-- In client
HRLib.RegCommand('teleport', function(args, rawCommand, IPlayer, FPlayer)
if args[1] == nil or args[2] == nil then
FPlayer.Notify('Invalid value! You must enter a value of `type` arg and `playerId` arg', 'error', 2500)
elseif args[1] == 'goto' then
if HRLib.DoesIdExist(args[2]) then -- Using HRLib.DoesIdExist to check args[2] argument for existing player server Id
FPlayer.Teleport(GetEntityCoords(args[2]), false)
else
FPlayer.Notify('This playerId is invalid!', 'error', 2500)
end
elseif args[1] == 'bring' then
if HRLib.DoesIdExist(args[2]) then -- Using HRLib.DoesIdExist to check args[2] argument for existing player server Id
HRLib.Teleport(args[2], GetEntityCoords(IPlayer.source), false)
else
FPlayer.Notify('This playerId is invalid!', 'error', 2500)
end
end
end, true, {help = 'Teleport someone to you or teleport yourself to someone', args = { {name = 'type', help = 'Type of teleport (goto, bring)'}, {name = 'playerId', help = 'existing player server Id'}} })
-- In server
HRLib.RegCommand('teleport', false, true, function(args, rawCommand, IPlayer, FPlayer)
if args[1] == nil or args[2] == nil then
FPlayer.Notify('Invalid value! You must enter a value of `type` arg and `playerId` arg', 'error', 2500)
elseif args[1] == 'goto' then
if HRLib.DoesIdExist(args[2]) then -- Using HRLib.DoesIdExist to check args[2] argument for existing player server Id
FPlayer.Teleport(GetEntityCoords(args[2]), false)
else
FPlayer.Notify('This playerId is invalid!', 'error', 2500)
end
elseif args[1] == 'bring' then
if HRLib.DoesIdExist(args[2]) then -- Using HRLib.DoesIdExist to check args[2] argument for existing player server Id
HRLib.Teleport(args[2], GetEntityCoords(IPlayer.source), false)
else
FPlayer.Notify('This playerId is invalid!', 'error', 2500)
end
end
end, true, {help = 'Teleport someone to you or teleport yourself to someone', args = { {name = 'type', help = 'Type of teleport (goto, bring)'}, {name = 'playerId', help = 'existing player server Id'}} })
playerId
integer
player server Id
yes