62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 09 Dec 2015 01:26 PM |
I wanted to make my own admin script for public use. Though I hate string manipulation, I can't get this working. It finds the command after the prefix, but it won't find the player. What I'm trying to do in this function is to return the command found in the text, and also the sub of the text of where the player's name should be found. Example:
(kill Player
So the function should return a sub of 5. So the getplr function starts at a sub of 5 to locate the player. I printed the sub it returned, and it only printed 1 blank space. e.e Here's the primary function that returns the sub.
local getcmd = function(txt) --Function to find the command written in the text for i,v in pairs(commands) do --commands is a tables which contain string local matching = 0 local length = string.len(v[1]) local runtime = 1 for i = 2,#txt do if txt:sub(i,i) == v[1]:sub(runtime,runtime) then matching = matching + 1 end if matching >= length then return v,i + 1 --'i+1' is the sub end runtime = runtime + 1 end end end |
|
|
| Report Abuse |
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 09 Dec 2015 01:34 PM |
| First bump It starts at the 2 char of the string in the for loop to avoid the prefix. |
|
|
| Report Abuse |
|