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
|
  |
| 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
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
| |
|
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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Jul 2015 01:27 PM |
| Dont use *, use + in this case. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 01:28 PM |
| @cntkillme But then wont that return nil if the seperator doesnt exist? |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 01:31 PM |
@fishguy
STOP GIVING PEOPLE MY FUNCTIONS YOU STUPID IDIOT |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Jul 2015 01:33 PM |
| Fish, its the other way around |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 27 Jul 2015 01:48 PM |
| You mean you steal my crap and try to frame me |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 01:49 PM |
| See? You cant go without replying to whatever I do. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
| |
|
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
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 27 Jul 2015 02:11 PM |
| It now works, thank you guys for your help. |
|
|
| Report Abuse |
|
|