|
| 27 Apr 2015 02:50 PM |
Admins = {"Player"} Players = { }
function findPlayers(name, speaker) if string.lower(name) == (name) then local chars = { } local c = game.Players:GetChildren() for i = 1, #c do if c[i].className == "Player" then table.insert(chars,c[i]) end end end end
I have no idea, I'm trying to work on something, so.
RAP:833,922 |
|
|
| Report Abuse |
|
|
Proxemics
|
  |
| Joined: 30 Oct 2013 |
| Total Posts: 2542 |
|
|
| 27 Apr 2015 02:58 PM |
| I really don't know strings and all, but isn't it string:lower()? |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 02:59 PM |
No idea to be honest. I was just looking through Person299's Admin..
RAP:833,922 |
|
|
| Report Abuse |
|
|
Proxemics
|
  |
| Joined: 30 Oct 2013 |
| Total Posts: 2542 |
|
|
| 27 Apr 2015 03:00 PM |
| Yeah I just check, it's :lower(). Person299's admin is ages old, so you might have to use another one for reference, lol. |
|
|
| Report Abuse |
|
|
Proxemics
|
  |
| Joined: 30 Oct 2013 |
| Total Posts: 2542 |
|
| |
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Apr 2015 03:01 PM |
| it can be written as string.lower(stringToLower), or be called as a method |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:02 PM |
@prox
you can call it with '.' too
> print(string.lower 'UPPER->LOWER') upper->lower
|
|
|
| Report Abuse |
|
|
Proxemics
|
  |
| Joined: 30 Oct 2013 |
| Total Posts: 2542 |
|
|
| 27 Apr 2015 03:04 PM |
Oh ok, glad you know. Well on my admin commands I always use :lower(), and since I don't know sht about strings, I wouldn't know haha |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:04 PM |
And OP, syntactically it is correct, but you may want to check some things.
Admins = {"Player"} Players = { }
function findPlayers(name, speaker) if string.lower(name) == (name) then -- is the first element of the conditional supposed to be the speaker's name? local chars = { } -- the table is named 'chars', but the players are inserted. local c = game.Players:GetChildren() for i = 1, #c do if c[i].className == "Player" then table.insert(chars,c[i]) end end end end |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:05 PM |
Okay, but would this work if I were to say something like.. ";Kill Noob" or something?
RAP:833,922 |
|
|
| Report Abuse |
|
|
Proxemics
|
  |
| Joined: 30 Oct 2013 |
| Total Posts: 2542 |
|
|
| 27 Apr 2015 03:06 PM |
Just use the chatted function, it makes things a lot less confusing. Of course you could still apply standard string things on it if you used chatted, |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:06 PM |
@Jimmy No. I'm intending the speaker to say something like "Kill Noob" and it kills the player. Would mine work?
RAP:833,922 |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:08 PM |
| well nothing is returned and I don't know how this is being used in the script |
|
|
| Report Abuse |
|
|
Proxemics
|
  |
| Joined: 30 Oct 2013 |
| Total Posts: 2542 |
|
|
| 27 Apr 2015 03:09 PM |
| As I said before, Durst, just use the chatted function. It's really easy. |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:10 PM |
I know it is, but Scripth/Kohl suggested I look through Person299's admin for all this.. ._.
RAP:833,922 |
|
|
| Report Abuse |
|
|
FlyScript
|
  |
| Joined: 05 Aug 2010 |
| Total Posts: 2884 |
|
|
| 27 Apr 2015 03:24 PM |
Prox, you don't know sht about strings yet you made admin commands?
That must have been pretty fking hellish for you then. |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:31 PM |
I'm thinking about re-writing my script sorta. I don't like to make stuff like "function functionName(blah,blah) end"
I prefer
game.Blah.Blah:connect(function(blah) end)
.-.
RAP:833,922 |
|
|
| Report Abuse |
|
|
| |
|
FlyScript
|
  |
| Joined: 05 Aug 2010 |
| Total Posts: 2884 |
|
|
| 27 Apr 2015 03:40 PM |
You mean you prefer anonymous functions? They're good, but if you make them connect to a named function, you can use that named function from other parts of your script if necessary, which can yield some cool/efficient results.
Although I would make them anonymous if you weren't going to use them anywhere else. |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:42 PM |
How's this so far then?
local Admin = {["Player"] = true}
function findPlayer(name) for _, c player in ipairs(game.Players:GetPlayers())do if player.Name:lower() == name:lower()then return player end end end function adminPlayer(message, player) if message:sub(1,7) == "!admin " and Admin[player.Name]then plr = findPlayer(message:sub(8)) if plr and plr.Character then table.insert(Admin, 1, "["plr.Name"] = true") end end end
RAP:833,922 |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:43 PM |
Wouldn't it be table.insert(Admin, 1, "["..plr.Name"] = true") ?
RAP:833,922 |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:48 PM |
scratch all of that
local admins = {"AbstractMadness","Player"}
function FindPlayer(name) return game:GetService("Players"):FindFirstChild(name) end
function IsAdmin(plr) for _,admin in next, admins do if admin == plr.Name then return true else return false end end end
function MakeAdmin(msg, chatter) if msg:sub(1,7):lower() == "!admin " and IsAdmin(chatter) then plr = FindPlayer(message:sub(8)) if plr and plr.Character then table.insert(admins, plr.Name) end end end |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:56 PM |
Would it need a Changed event for players to use the commands?
RAP:833,922 |
|
|
| Report Abuse |
|
|
FlyScript
|
  |
| Joined: 05 Aug 2010 |
| Total Posts: 2884 |
|
|
| 27 Apr 2015 03:56 PM |
Why are you doing it like that? Just have a list of actual names.
It would be easier to search admins if you did it with instances.
In this example, you would also be able to set their privilege level (like 1 for a temp, 2 for a normal, 3 for a special, 4 for owner, whatever).
I recommend using a system that goes by userIds, so you don't have to change the script if an admin changes their name.
ownerAdmins = {myID} specialAdmins = {someID, someOtherID} normalAdmins = {otherID, anotherID, yetAnotherID} termpAdmins = {}
admins = Instance.new("Folder", script) admins.Name = "Admins"
for _, v in pairs(ownerAdmins) do local admin = Instance.new("IntValue", admins) admin.Name, admin.Value = tostring(v), 4 end
for _, v in pairs(specialAdmins) do local admin = Instance.new("IntValue", admins) admin.Name, admin.Value = tostring(v), 3 end
for _, v in pairs(normalAdmins) do local admin = Instance.new("IntValue", admins) admin.Name, admin.Value = tostring(v), 2 end
for _, v in pairs(tempAdmins) do local admin = Instance.new("IntValue", admins) admin.Name, admin.Value = tostring(v), 1 end
This way you can do admins:FindFirstCHild(player.userId) and easily check their privileges and stuff.
|
|
|
| Report Abuse |
|
|
|
| 27 Apr 2015 03:57 PM |
>for _,admin in next, admins do
Uhh, "in next"?
RAP:833,922 |
|
|
| Report Abuse |
|
|