Shoqwave
|
  |
| Joined: 13 May 2012 |
| Total Posts: 215 |
|
|
| 11 May 2013 03:25 PM |
I had started creating commands, today, and I have been constantly testing it. Below are the vital parts. When I use the ":kill" command, it works fine, but when I use the ":ban" command, it errors, and the script breaks. I don't know why this is, however.
----------
commands = { ["kill"] = function(player) if (player.Character) then player.Character:BreakJoints(); end; end;
["ban"] = function(player) players[player.Name] = 0; player:Destroy(); end; };
----------
function findPlayer(pattern) local list = {}
for _, v in pairs(game.Players:GetPlayers()) do if (string.find(v.Name:lower(), pattern:lower())) then table.insert(list, v); end; end;
if (#list ~= 0) then return list; end; end;
----------
function onCmd(msg, spkr) if (string.sub(msg:lower(), 1, 6) == ":kill ") and (players[spkr.Name] > 1) then local list = findPlayer(msg:sub(7));
for _, v in pairs(list) do commands.kill(v); end; elseif (string.sub(msg:lower(), 1, 5) == ":ban ") and (players[spkr.Name] > 2) then local list = findPlayers(msg:sub(6));
for _, v in pairs(list) do commands.ban(v); end; end; end; |
|
|
| Report Abuse |
|
|
WishNite
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 15828 |
|
|
| 11 May 2013 03:28 PM |
| I'm pretty sure you didn't define players |
|
|
| Report Abuse |
|
|
Shoqwave
|
  |
| Joined: 13 May 2012 |
| Total Posts: 215 |
|
|
| 11 May 2013 03:30 PM |
| I did, and I also noted that it broke at the command ":ban" instead of not working all together. |
|
|
| Report Abuse |
|
|
Shoqwave
|
  |
| Joined: 13 May 2012 |
| Total Posts: 215 |
|
| |
|
Shoqwave
|
  |
| Joined: 13 May 2012 |
| Total Posts: 215 |
|
| |
|
WishNite
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 15828 |
|
|
| 11 May 2013 03:58 PM |
| Where did you define the players table??? |
|
|
| Report Abuse |
|
|
Shoqwave
|
  |
| Joined: 13 May 2012 |
| Total Posts: 215 |
|
|
| 11 May 2013 04:00 PM |
I thought it wasn't vital (which, it really isn't), so I didn't add it.
players = {["Shoqwave"] = 4, ["Player2"] = 0} |
|
|
| Report Abuse |
|
|
WishNite
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 15828 |
|
|
| 11 May 2013 04:03 PM |
It is vital, as if you try putting that into the command line, it doesn't work
14:02:48.327 - players["string"] = 1:1: attempt to index global 'players' (a nil value) 14:02:48.328 - Script "players["string"] = 1", Line 1 14:02:48.329 - stack end |
|
|
| Report Abuse |
|
|
Shoqwave
|
  |
| Joined: 13 May 2012 |
| Total Posts: 215 |
|
|
| 11 May 2013 04:05 PM |
Looks non-vital to me.
array = {} array["Test"] = 1 print(array["Test"]) |
|
|
| Report Abuse |
|
|
Shoqwave
|
  |
| Joined: 13 May 2012 |
| Total Posts: 215 |
|
|
| 11 May 2013 04:15 PM |
Thank you for literally no help. I figured out the problem, it was a simple typo, and had nothing to do with the non-vital table. |
|
|
| Report Abuse |
|
|
WishNite
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 15828 |
|
|
| 11 May 2013 04:17 PM |
| I was the only one who tried to help, sorry for the attempt |
|
|
| Report Abuse |
|
|