generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Admin commands...

Previous Thread :: Next Thread 
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
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 is not online. 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 is not online. ash877
Joined: 18 Feb 2008
Total Posts: 5142
22 Jun 2015 11:56 PM
plr.Name should be v.Name
Report Abuse
Froast is not online. 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
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
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 is not online. 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 is not online. 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
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
23 Jun 2015 12:01 AM
@my script

kill(v)*
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
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 is not online. 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
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
23 Jun 2015 12:23 AM
@Jimmy

I used string.sub to fix that.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image