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: Help with strings

Previous Thread :: Next Thread 
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
27 Jul 2015 12:56 PM
I am making an admin script.

How can I detect what they say before '/' and after?

So if they said 'kill/all' it would detect 'kill' and 'all'

And no, not string,sub(msg,1,4) because that would only detect the first four letters
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
27 Jul 2015 01:00 PM
if msg:find("/") then
msg:sub(1,msg:find("/")-1)
end
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
27 Jul 2015 01:02 PM
thanks!
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
27 Jul 2015 01:04 PM
And I'm guessing to get after "/" it is:

if msg:find("/") then
string.sub(msg,1,(msg:find("/")+1))
end
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Jul 2015 01:22 PM
You'll run into problems doing that when you want to expand. IE tp/a/b
Creating a string.split type function that splits each part of the string aeparated by / to an array.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
27 Jul 2015 01:26 PM
Here is a string splitter function:

local function SplitString(Text,Breakpoint)
local StringParts = {};


for StringSection in Text:gmatch('[^'..Breakpoint..']*') do
table.insert(StringParts,StringSection);
end;


return StringParts;
end;
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Jul 2015 01:27 PM
Dont use *, use + in this case.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
27 Jul 2015 01:28 PM
@cntkillme But then wont that return nil if the seperator doesnt exist?
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
27 Jul 2015 01:31 PM
@fishguy


STOP GIVING PEOPLE MY FUNCTIONS YOU STUPID IDIOT
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Jul 2015 01:33 PM
Fish, its the other way around
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
27 Jul 2015 01:34 PM
LOOK
THIS IS STRAIGHT FROM MY ADMIN
HE TOOK IT AND MODDED IT

local function SplitString(Text,Breakpoint)
local StringParts = {}
for StringSection in Text:gmatch('[^'..Breakpoint..']*') do
table.insert(StringParts,StringSection)
end
return StringParts
end
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
27 Jul 2015 01:38 PM
ACTUALLY I GAVE YOU THAT FUNCTION.

@cntkillme Can I have the link to your string patterns article again?
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
27 Jul 2015 01:40 PM
NO YOU DIDNT
GERGY008 ORIGINALLY FOUND ME ONE, THEN I MADE MY OWN, AND THEN GOT IT MADE MORE EFFICIENT BY A NICE GUY ON THE FORUM YOU STUPID FAT LIAR
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
27 Jul 2015 01:42 PM
Actually, I made this function and gave it to you. You originally gave me his and I made it ALOT more efficient.
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
27 Jul 2015 01:42 PM
NO YOU DIDNT
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
27 Jul 2015 01:43 PM
Stop spamming on a thread for help. And dont say "You stop spamming" because I am trying to get you to stop. This guy wanted help so I helped him.
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
27 Jul 2015 01:45 PM
YEA BY STEALING MY STUFF
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
27 Jul 2015 01:47 PM
I didnt steal it. Can you go ONE time without answering to my replies? Listen, stop making a fool out of yourself by framing me over and over because I IMPROVED upon HIS(not yours) function.
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
27 Jul 2015 01:48 PM
You mean you steal my crap and try to frame me
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
27 Jul 2015 01:49 PM
See? You cant go without replying to whatever I do.
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
27 Jul 2015 01:53 PM
Here, String Patterns and Matching: http://www.roblox.com/Forum/ShowPost.aspx?PostID=166129154

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
27 Jul 2015 01:54 PM
AdminCommands = {
['kill'] = function(plr,msger)
if plr.Character then
plr.Charatcer:BreakJoints()
end
end;
}




game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
if msg:find("/") then
local cmd = string.sub(msg,1,(msg:find("/")+1))
if AdminCommands[cmd:lower()]then
local func = AdminCommands[cmd:lower()](p,p)
end
end
end)
end)


--Whats wrong with this?

Right now I have it set so that anyone can type 'kill/' and it 'should' call the function: AdminCommands.kill(p,p) and i have both set to the player that typed(p) for testing purposes.
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
27 Jul 2015 02:01 PM
bump
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
27 Jul 2015 02:07 PM
...

I now realize I put '+' instead of '-'

I will get back to everyone to say if it works.
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
27 Jul 2015 02:11 PM
It now works, thank you guys for your help.
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