First of all, i’m sorry for the newbie question.
I’m inexperienced with LUA and the FiveM thematic.
RegisterCommand("help", function(source)
local playerName = GetPlayerName(source)
serverMsg("Welcome: " + playerName)
end, false)
I seem to fail to understand, getting the user ID (source) and convert the string to a local (playerName) and outputing it in an serverMsg.
Any help, beginner tricks and/or tipps
If I understood corretly you have problem with these line:
serverMsg("Welcome: " + playerName)
And I think your problem is concatenate in lua because unfortunetly it doesn’t work the same as in different programming languages.
So the solution is to corretly concatenate the string to variable like:
serverMsg("Welcome: " .. playerName)
-- Change number to string
tostring(playerName)
So if /help is called the PlayerID displayed as source.
Gets saved and put in local playerName = GetPlayerName(source) which should give me the playerName.
GetPlayerName requires an id = source.
Changing
serverMsg("Welcome: " + playerName)
to
serverMsg("Welcome: " .. playerName)
Did not helped, why using
tostring(playerName)
If already string?