|
| 09 Jun 2014 11:05 AM |
Hello everyone, my name is jordan83221. I am an elite Admin creator for the popular game, "Script Builder". My goal here today is to show new, or even old, admin scripters a new way to get the most out of your admin scripts.
What I see most of the time is admin scripts like this:
function onChatted(msg) if string.sub(msg,1,5):lower() == "kill/" then etc. etc. etc. end end
I agree, this is perfectly fine, but this is old, outdated, and just weak. I am going to introduce to you something called "String Parsing". Now, what string parsing is, is where you take a string and search for matches. e.g, function onChatted(msg) a,b=msg:match("(%w*)/(%w*)") if a then -- I'll show you the rest later. end end end
What that does is it starts a function called onChatted, then it searches two different things, a is what's said in the first set of parenthesis, and b is what's said in the second set of parenthesis. Then it checks if a is said.
This is a very efficient way to make your admin scripts, the reason is that it uses tables and functions to create commands.
--First start off with an array:
cmds={}
--Now for the easiest start of commands ever.
cmds["kill"]=function() --What this is doing is it is creating a function in the array "cmds" end
So, let's rewrite it.
cmds={} admins={"jordan83221"}
cmds["kill"]=function(plr) --Now you can go ahead and get your getPlayers() function from an old admin script. for _,v in next,game.Players:GetPlayers() do if string.find(v.Name:lower(),plr:lower()) ~= nil then ypcall(function() v.Character:BreakJoints() end) end end end
--Now, let's wrap it up with a simple onChatted function.
function onChatted(msg) --Now there are two ways of doing this, both are basically the same. --You can either use: _,_,cmd,p=msg:find() --Or you can use cmd,p=msg:match() You choose. I use match so let's use that. cmd,p=msg:match("^(%w*)/(%w*)") --The %w* is checking for all numbers and letters. The / is what came after that, then the second %w* is the same thing. if cmd then ypcall(function() cmd=cmd:lower() --Setting the command lower incase of caps. if cmds[cmd] then --Checking if the word that was said is the name of a function in the table "cmds" cmds[cmd](p) --Running the function with the arguments "p" end end) end end --Now let's make a function for a new player that joined.
function onEntered(plr) if plr:IsA("Player") then for _,v in next,admins do if plr.Name==v then plr.Chatted:connect(function(m) onChatted(m) end) end end end end game.Players.PlayerAdded:connect(onEntered) for _,v in next,game.Players:GetPlayers() do onEntered(v) end
The rest is fairly selfexplanitory. And don't worry, it works.
Now, let's talk about double "/" commands...
This is the exact same concept, you'll be surprised about how easy it is.
cmds2={}
cmds2["ws"]=function(plr,spd) --2 arguments, one for speed, one for player for _,v in next,game.Players:GetPlayers() if string.find(v.Name:lower(),plr:lower()) ~= nil then ypcall(function() if v.Character then v.Character.Humanoid.WalkSpeed = spd end end end end end
--Now we make a new onChatted function
function onChatted2(msg) cmd2,p2,extra=msg:match("^(%w*)/(%w*)/([%s%w]*)") -- You can make it the same as the others if you really want to, but the brackets make it so if you are pming someone, you can say full messages past the second "/" instead of just one word or number, but it still works as one number. if cmd2 then ypcall(function() cmd=cmd:lower() if cmds2[cmd2] then cmds2[cmd2](p2,extra) end end end end
--Now, all you have to do is call the function in the same onEntered function,
plr.Chatted:connect(function(m) onChatted2(m) end)
And there we have it.
Now, the reason I showed you this is because it is a very efficient, and easy to use way of getting the most out of your admin scripts.
Thanks for reading!
Regards: jordan83221
|
|
|
| Report Abuse |
|
|
bohdan77
|
  |
| Joined: 10 Aug 2008 |
| Total Posts: 7944 |
|
|
| 09 Jun 2014 11:09 AM |
| I'm just going to lay down, and close my eyes. |
|
|
| Report Abuse |
|
|
| |
|
Devoi
|
  |
| Joined: 09 Jun 2013 |
| Total Posts: 5387 |
|
|
| 09 Jun 2014 02:04 PM |
| op we already know this stuff |
|
|
| Report Abuse |
|
|
LuaSir
|
  |
| Joined: 30 Mar 2014 |
| Total Posts: 40 |
|
| |
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 09 Jun 2014 04:34 PM |
| basic lua which everyone should know but don't because they're bad people |
|
|
| Report Abuse |
|
|
|
| 09 Jun 2014 05:12 PM |
| You should put this on the wiki or something. |
|
|
| Report Abuse |
|
|
Insoul
|
  |
| Joined: 04 May 2014 |
| Total Posts: 66 |
|
|
| 09 Jun 2014 09:30 PM |
this kid is implying we should use 'his method' nah using string sub is fine but Im crying
herro Im syKo |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 12:29 AM |
| I'm not "implying" that you do anything. I am merely giving a suggesting thought that has helped me throughout my time and I think it will help others as well. Children these days. |
|
|
| Report Abuse |
|
|
BLOXLUA
|
  |
| Joined: 16 Mar 2013 |
| Total Posts: 453 |
|
|
| 10 Jun 2014 01:36 AM |
| I think this method looks gross. |
|
|
| Report Abuse |
|
|
Insoul
|
  |
| Joined: 04 May 2014 |
| Total Posts: 66 |
|
|
| 10 Jun 2014 08:14 AM |
ya your method is ugly Ill stick to string subs unless I want to waste a bunch of character space
herro Im syKo |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 10 Jun 2014 09:32 AM |
oh also;
function OnChat(plyr, msg) local cmd, args = nil, { } for arg in msg:gmatch("[^/]+") do if not cmd then cmd = arg else args[#args+1] = arg end end ParseCommand(cmd, args) end
less lines and better |
|
|
| Report Abuse |
|
|
xSIXx
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 9202 |
|
|
| 10 Jun 2014 04:40 PM |
"I am an elite Admin creator for the popular game, "Script Builder". "
you are not going to get very far with admin commands in a game invested with free model orb users. |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 08:56 PM |
^ this and what is the point of making admin scripts on script builder? :Q |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2014 03:07 AM |
| You just copied a post from long ago,I'm 90% sure of that, I've already seen this somewhere. |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2014 05:37 PM |
Dark, you are correct, this is a remake of an old post made by someone who I cannot remember. Anyway, insulting me for trying to help is just wasting your time. This is for people who want to learn more about scripting in general. This is not for elite scripters who have been scripting for 5+ years. string.sub is old, boring, and frankly a waste of code. I wrote a 5 bet cmd in about 30 seconds.
"(%w*)_(%w*)_(%w*)_(%w*)_(%w*)" that's it and it runs a 5 bet command. Do that with string.sub in a single line...
This is for newer scripters who just want to learn more about making their admins better, more efficient, and stronger to use in their places, or SB. Insult me all day long, you'll just be wasting your own time. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 13 Jun 2014 05:40 PM |
'This is not for elite scripters who have been scripting for 5+ years.' I've been scripting Lua much, much less and this is still a stupid way to do it.
Plus, wrong forum, Mr. Elite Scripter |
|
|
| Report Abuse |
|
|
databrain
|
  |
| Joined: 01 Jan 2013 |
| Total Posts: 3342 |
|
|
| 13 Jun 2014 06:29 PM |
I don't understand any of this.
I just use string.sub, and made my own split/join API do do stuff.
http://www.roblox.com/Datas-Admin-V1-0-5-item?id=157713571 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 13 Jun 2014 06:31 PM |
| Splitting is much cleaner and better than this. |
|
|
| Report Abuse |
|
|
Insoul
|
  |
| Joined: 04 May 2014 |
| Total Posts: 66 |
|
|
| 15 Jun 2014 12:22 PM |
wait wait wait is this kid a boy/girl? or like wtf
herro Im syKo |
|
|
| Report Abuse |
|
|
|
| 15 Jun 2014 01:48 PM |
>Insoul
Because gender matters when it games to using a computer, correct? |
|
|
| Report Abuse |
|
|
Insoul
|
  |
| Joined: 04 May 2014 |
| Total Posts: 66 |
|
|
| 15 Jun 2014 04:53 PM |
>legoman
no its just that his name and then the appearance kinda side tracked me o.O
herro Im syKo
|
|
|
| Report Abuse |
|
|
|
| 15 Jun 2014 09:07 PM |
| Yet Jordan is a common name among females. Here, let me hold your hand and help you escape from the rock you have been living under.. |
|
|
| Report Abuse |
|
|
| |
|
|
| 19 Jun 2014 01:02 AM |
| but what about the core hyper-mainframe flux??? |
|
|
| Report Abuse |
|
|