|
| 22 Jun 2015 11:53 PM |
So, I know how to make a command like
:kill AbstractMadness
but how would I make it so I wouldn't have to type the full name and it can be lowercase like this
:kill abs
I'm guessing :sub() and :lower() but I want to see an example, please.
Thank you for helping. :P |
|
|
| Report Abuse |
|
|
ash877
|
  |
| Joined: 18 Feb 2008 |
| Total Posts: 5142 |
|
|
| 22 Jun 2015 11:55 PM |
for _,v in pairs(game.Players:GetPlayers()) do if string.find(plr.Name,"AbstractMadness") then print(":c") end end |
|
|
| Report Abuse |
|
|
ash877
|
  |
| Joined: 18 Feb 2008 |
| Total Posts: 5142 |
|
| |
|
Froast
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 3134 |
|
|
| 22 Jun 2015 11:57 PM |
local getPlayer = function(name) for _,plr in next, game:GetService'Players':GetPlayers() do if plr.Name:sub(1,#name):lower() == name:lower() then return plr end end end |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2015 11:57 PM |
my go at it is:
local command = ":kill abs"
if cmd:sub(1,6):lower() == ":kill " then local plr = cmd:match(":kill (.+)") for i,v in next, game.Players:GetPlayers() do if v.Name:lower():sub(1,#plr) then kill(game.Players[plr]) end end end
idk if that even works tho |
|
|
| Report Abuse |
|
|
ash877
|
  |
| Joined: 18 Feb 2008 |
| Total Posts: 5142 |
|
|
| 22 Jun 2015 11:57 PM |
function conv(str) for _,v in pairs(game.Players:GetPlayers()) do if string.find(v.Name,str) then print(":c") end end end
conv("AbstractMadness")
|
|
|
| Report Abuse |
|
|
ash877
|
  |
| Joined: 18 Feb 2008 |
| Total Posts: 5142 |
|
|
| 23 Jun 2015 12:00 AM |
function conv(str) local cnum=0 for _,v in pairs(game.Players:GetPlayers()) do if string.find(v.Name:lower(),str:lower()) then cnum=cnum+1 print("FOUND") end --cnum++ end if cnum==1 then return 1 elseif cnum==0 then return 0 elseif cnum>1 then return -1 end
num=conv("abs") if num==1 then print("Found") elseif num==0 then print("Not found") elseif num==-1 then print("Found many") end |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Jun 2015 12:05 AM |
local GetPlayer = function(Name) local Returned = { } local Pattern = "^" .. string.lower(Name) for _, Player in next, game.Players:GetPlayers() do if string.lower(Player.Name):match(Pattern) then table.insert(Returned, Player) end end return Returned end
Without the anchor, it will return true if it detects the pattern anywhere (so someone could say ":kill mad") IIRC. |
|
|
| Report Abuse |
|
|
ash877
|
  |
| Joined: 18 Feb 2008 |
| Total Posts: 5142 |
|
|
| 23 Jun 2015 12:09 AM |
function conv(str) local cnum=0 for _,v in pairs(game.Players:GetPlayers()) do if string.find(v.Name:lower(),str:lower(),1,false) then cnum=cnum+1 end end if cnum==1 then return 1 elseif cnum==0 then return 0 elseif cnum>1 then return -1 end end
num=conv("abs") if num==1 then print("Found") elseif num==0 then print("Not found") elseif num==-1 then print("Found many") end
--No need for anchor. |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2015 12:23 AM |
@Jimmy
I used string.sub to fix that. |
|
|
| Report Abuse |
|
|