LucasBaker Posted November 28, 2013 Share Posted November 28, 2013 because I am unable to generate the nick of targetPlayer? function gerarI (targetPLayer) local target = getPlayerFromName (targetPlayer) local geta = getPlayerName (target) outputChatBox ( "Nome: "..targetPlayer, getRootElement(), 255, 0, 0, true ) end addCommandHandler ( "pc", gerarI ) Link to comment
Spajk Posted November 28, 2013 Share Posted November 28, 2013 Parameters for command handler are: player playerSource, string commandName, [string arg1, string arg2, ...] So replace: function gerarI (targetPLayer) with: function gerarI (player, cmd, targetPlayer) Also, getPlayerFromName requiers the player to enter the FULL name of target player. You should check out this snippet: https://wiki.multitheftauto.com/wiki/Ge ... omNamePart Link to comment
DNL291 Posted November 28, 2013 Share Posted November 28, 2013 function gerarI (player, cmdName, targetPlayer) local target = getPlayerFromNamePart(targetPlayer) local geta = getPlayerName (target) outputChatBox ( "Nome: "..geta, getRootElement(), 255, 0, 0, true ) end addCommandHandler ( "pc", gerarI ) function getPlayerFromNamePart(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now