King12 Posted October 7, 2017 Share Posted October 7, 2017 Hello, I've used the "getPlayerFromPartialName", but always returns that player wasn't found and no errors in debugscript. function getPlayerFromPartialName(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 function betOnPlayer ( player, cmd, amount, player2 ) if amount and player2 then local player1 = getPlayerFromPartialName ( player2 ) if player1 then -- code here else outputChatBox ( "#ff1111Player not found!", player, 255, 255, 255, true ) end else outputChatBox ( "#660000Use: #ffffff'/bet [player] [amount]' ..", player, 255, 255, 255, true ) end end Link to comment
itHyperoX Posted October 7, 2017 Share Posted October 7, 2017 (edited) function betOnPlayer(source, cmd, amount, target) if amount then iprint("Amount") if target then local targetPlayer = getPlayerFromPartialName(target) outputChatBox("The player name is "..getPlayerName(targetPlayer), source) iprint("Target found!") --- Your code here. else iprint("No target player") end else outputChatBox("/"..cmd.." [Amount] [Target]", source) end end Edited October 7, 2017 by TheMOG 1 Link to comment
King12 Posted October 7, 2017 Author Share Posted October 7, 2017 2 hours ago, TheMOG said: function betOnPlayer(source, cmd, amount, target) if amount then iprint("Amount") if target then local targetPlayer = getPlayerFromPartialName(target) outputChatBox("The player name is "..getPlayerName(targetPlayer), source) iprint("Target found!") --- Your code here. else iprint("No target player") end else outputChatBox("/"..cmd.." [Amount] [Target]", source) end end Worked. Thanks. 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