RegisterCommand('vida2', async (source, args, raw) => {
let playerName = GetPlayerName(-1);
if (args[0] == null)
{
emit('chat:addMessage', {
args: [`Teste!`]
});
}
else
{
ped = GetPlayerPed(args[0]);
emit('chat:addMessage', {
args: [`The player name is ${playerName}!`]
});
}
}, false);
Hi. I made this code where if args[0] is not null I get sent a message with my player name (local). However it is returning Invalid . What is wrong?
GetPlayerName(PlayerId()), -1 is only a valid alias for GetPlayerPed.
1 Like
Thanks! How could I get the player name of other player??
I tried this but it isn’t working:
let playerIdentifier = GetPlayerIdentifier(args[0]);
D4NE
June 19, 2021, 7:05pm
4
KhabibAlmeidowski:
GetPlayerIdentifier
GetPlayerIdentifier need 2 params.
playerSrc and 2. the identifier that you want to request
And where can I see a list of those identifiers?
They don’t show up in here
D4NE
June 19, 2021, 7:07pm
6
Just use GetPlayerName as before
D4NE
June 19, 2021, 7:08pm
7
You just need the PlayersSource, and that sould be that what you got
local playerName = GetPlayerName(playerSrc);
And how can I get the player ped of another player?
I’ve tried this:
ped = GetPlayerPed(args[0]);
I’m supposed to type his name on chat
D4NE
June 19, 2021, 7:19pm
9
Yeah. OKay. But you dont need to get the ped for the chat? and yeah that should be right
I’m trying to do a command where I heal a player’s ped by typing /heal [playerName].
I think it’s working now.
Not I’ll try to check if the player is connected to the server
zee
June 21, 2021, 12:28pm
11
They’re dynamically indexed. Use Array.prototype.find on getPlayerIdentifiers to get the identifier you want.