MRThinker Posted July 27, 2018 Share Posted July 27, 2018 i'm writing a police department faction but i have a problem! how to writing a find player system? thePlayer use /find <playerid> and target showing on radar with blip id 56. plz help me, thanks! Link to comment
xMKHx Posted July 27, 2018 Share Posted July 27, 2018 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 findPlayer (player, cmd, target) local target_ = getPlayerFromPartialName ( target ) local targetN = getPlayerName(target_) if cmd == "find" then if target_ then createBlipAttachedTo ( getPlayerFromName(targetN), 56 ) else outputChatBox("Player not found !", player, 255, 0, 0) end end end addCommandHandler("find", findPlayer) Link to comment
MRThinker Posted July 27, 2018 Author Share Posted July 27, 2018 3 minutes ago, xMKHx said: 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 findPlayer (player, cmd, target) local target_ = getPlayerFromPartialName ( target ) local targetN = getPlayerName(target_) if cmd == "find" then if target_ then createBlipAttachedTo ( getPlayerFromName(targetN), 56 ) else outputChatBox("Player not found !", player, 255, 0, 0) end end end addCommandHandler("find", findPlayer) not working... this script is attach blip for all players. no for thePlayer or more... Link to comment
xMKHx Posted July 27, 2018 Share Posted July 27, 2018 try this function find (player, cmd, target) local target_ = getPlayerFromName(target) if target_ then local targetN = getPlayerName(target_) createBlipAttachedTo(target_, 56) else outputChatBox("Sorry, we don't know a person called" .. targetN, target_, 255, 0, 0) end end addCommandHandler("find", find) Link to comment
MRThinker Posted July 27, 2018 Author Share Posted July 27, 2018 10 hours ago, xMKHx said: try this function find (player, cmd, target) local target_ = getPlayerFromName(target) if target_ then local targetN = getPlayerName(target_) createBlipAttachedTo(target_, 56) else outputChatBox("Sorry, we don't know a person called" .. targetN, target_, 255, 0, 0) end end addCommandHandler("find", find) thanks, well done... 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