Klesh Posted January 29, 2012 Share Posted January 29, 2012 I was try to make some function to later insert it for a command script: function getPlayerFromPartOfName(nickpart) local players=getElementsByType("player") local matches={} for _,v in pairs(players) do if string.find(string.lower(getPlayerFromName(v)),string.lower(nickpart)) then table.insert(matches,v) end end if #mathces>1 then return false else return mathces[1] end end Link to comment
Castillo Posted January 29, 2012 Share Posted January 29, 2012 And what doesn't work from it? Link to comment
Klesh Posted January 29, 2012 Author Share Posted January 29, 2012 It doesn't, writing a partial name, for example kles, does not works. System : addCommandHandler("lol", function ( thePlayer, commandName, who) bugPlayer = getPlayerFromPartOfName(who) --------Example---------- Link to comment
Castillo Posted January 29, 2012 Share Posted January 29, 2012 Maybe because you used getPlayerFromName instead of getPlayerName in line: 5. Also you put "mathces" instead of "matches". function getPlayerFromPartOfName(nickpart) local players=getElementsByType("player") local matches={} for _,v in pairs(players) do if string.find(string.lower(getPlayerName(v)),string.lower(nickpart)) then table.insert(matches,v) end end if #matches>1 then return false else return matches[1] end end Link to comment
Klesh Posted January 29, 2012 Author Share Posted January 29, 2012 Not works. function getPlayerFromPartOfName(nickpart) local players=getElementsByType("player") local matches={} for _,v in pairs(players) do if string.find(string.lower(getPlayerName(v)),string.lower(nickpart)) then table.insert(matches,v) end end if #matches>1 then return false else return matches[1] end end Link to comment
Castillo Posted January 29, 2012 Share Posted January 29, 2012 function getPlayerFromPartOfName(nickpart) local players=getElementsByType("player") local matches={} for _,v in pairs(players) do if string.find(string.lower(getPlayerName(v)),string.lower(nickpart)) then table.insert(matches,v) end end if (#matches > 1) then return false else return matches[1] end end addCommandHandler("part", function (thePlayer, cmd, who) local player = getPlayerFromPartOfName(who) if (player) then outputChatBox(getPlayerName(player)) end end) Works perfectly. I do /part cast and it outputs (SAUR)Castillo. Link to comment
Klesh Posted January 29, 2012 Author Share Posted January 29, 2012 Was working, just was a bug of the server, it wasn't save the script. Can delete this topic please?, it goes for community Link to comment
Castillo Posted January 29, 2012 Share Posted January 29, 2012 Why delete the topic? if you post here you should know that it's going to be public. It could help someone else with a similar problem. Not going to be deleted. Link to comment
Klesh Posted January 29, 2012 Author Share Posted January 29, 2012 If someone else post this with a different author, can get deleted from community? Link to comment
Castillo Posted January 29, 2012 Share Posted January 29, 2012 You can report the resource, yes. Link to comment
AGENT_STEELMEAT Posted January 29, 2012 Share Posted January 29, 2012 Ehh no, any scripts / parts of scripts posted in this section should be considered public domain. 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