micol2242
|
  |
| Joined: 13 Nov 2010 |
| Total Posts: 4732 |
|
|
| 27 Apr 2012 09:08 PM |
I don't understand what I'm doing wrong. It will ban the player, but then they can come back to the game. Output shows nothing, and that "Crasher" script is just a local script that has "while true do end" in it.
admins = {"micol2242"} Players = {} BannedPlayers = {}
function findIndex(Table, Value) for _, v in pairs(Table) do if v == Value then return _ end end return 0 end
function getMatchedPlayer(String, speaker) for _, v in pairs(game.Players:GetPlayers()) do if v~=speaker and v.Name:lower():match(String:lower()) then return v end end end
function isAdmin(player) local is = false for _,v in pairs(admins) do if player.Name == v then return true end end return false end
function BAN(pl) c = script.Crasher:Clone() c.Parent = pl.Backpack c.Disabled = false pl.Character:Destroy() end
game.Players.PlayerAdded:connect(function(address) table.insert(Players, (game.Players.PlayerAdded:wait()).Name) end)
game.Players.PlayerAdded:connect(function(p) b = Instance.new("BoolValue",p) b.Name = "Banned" p:WaitForDataReady() p:LoadBoolean("IP") wait() if p.Banned.Value == true then if findIndex(BannedPlayers, Players[findIndex(Players, p.Name)])~=0 then if p ~= nil then p:Remove() end end end p.Chatted:connect(function(msg) if not isAdmin(p) then return end local m = string.sub(msg, 1, 6) if m == "dpban/" then local pl = getMatchedPlayer(msg:sub(7), p) if pl ~= nil then pl.Banned.Value = true table.insert(BannedPlayers, pl.Name) if not pl.DataReady then pl:WaitForDataReady() end pl:SaveBoolean("IP",pl.Banned.Value) BAN(pl) end end end) end)
game.Players.PlayerRemoving:connect(function(p) local ind = findIndex(Players, p.Name) table.remove(Players, ind) end)
- I have a pen, the pen is blue, I have a friend, the friend is U! - |
|
|
| Report Abuse |
|
|
L2000
|
  |
| Joined: 03 Apr 2008 |
| Total Posts: 77448 |
|
|
| 27 Apr 2012 09:26 PM |
p:LoadBoolean("IP") if p.Banned.Value == true then
This will never happen, as it doesn't save the value and instead saves true or false. As you are not setting the value to this, it will not change the value for p.Banned.
To fix this, simply go: if p:LoadBoolean("IP") then
Which checks for the value of IP to be true, and if it is, continues.
-- Also, just a bit of a side note -- Did the forums get updated? I can see tabs, which were never allowed before.
admins = {"micol2242"} Players = {} BannedPlayers = {}
function findIndex(Table, Value) for _, v in pairs(Table) do if v == Value then return _ end end return 0 end
function getMatchedPlayer(String, speaker) for _, v in pairs(game.Players:GetPlayers()) do if v~=speaker and v.Name:lower():match(String:lower()) then return v end end end
function isAdmin(player) local is = false for _,v in pairs(admins) do if player.Name == v then return true end end return false end
function BAN(pl) c = script.Crasher:Clone() c.Parent = pl.Backpack c.Disabled = false pl.Character:Destroy() end
game.Players.PlayerAdded:connect(function(address) table.insert(Players, (game.Players.PlayerAdded:wait()).Name) end)
game.Players.PlayerAdded:connect(function(p) b = Instance.new("BoolValue",p) b.Name = "Banned" p:WaitForDataReady() if p:LoadBoolean("IP") then wait() if findIndex(BannedPlayers, Players[findIndex(Players, p.Name)])~=0 then if p ~= nil then p:Remove() end end end p.Chatted:connect(function(msg) if not isAdmin(p) then return end local m = string.sub(msg, 1, 6) if m == "dpban/" then local pl = getMatchedPlayer(msg:sub(7), p) if pl ~= nil then pl.Banned.Value = true table.insert(BannedPlayers, pl.Name) if not pl.DataReady then pl:WaitForDataReady() end pl:SaveBoolean("IP",pl.Banned.Value) BAN(pl) end end end) end)
game.Players.PlayerRemoving:connect(function(p) local ind = findIndex(Players, p.Name) table.remove(Players, ind) end) |
|
|
| Report Abuse |
|
|
micol2242
|
  |
| Joined: 13 Nov 2010 |
| Total Posts: 4732 |
|
|
| 27 Apr 2012 09:36 PM |
That didn't work, the player who I banned could still come back in another server (yes, a new one)
- I have a pen, the pen is blue, I have a friend, the friend is U! - |
|
|
| Report Abuse |
|
|
micol2242
|
  |
| Joined: 13 Nov 2010 |
| Total Posts: 4732 |
|
|
| 27 Apr 2012 09:50 PM |
L2 OPLS I am very confused as to why this isn't working, there is obviously something with the saving?
- I have a pen, the pen is blue, I have a friend, the friend is U! - |
|
|
| Report Abuse |
|
|
L2000
|
  |
| Joined: 03 Apr 2008 |
| Total Posts: 77448 |
|
|
| 27 Apr 2012 09:58 PM |
The problem is probably that they're not inserted into the table in other servers. Remove the line where it checks for that and it should work in all servers.
admins = {"micol2242"} Players = {} BannedPlayers = {}
function findIndex(Table, Value) for _, v in pairs(Table) do if v == Value then return _ end end return 0 end
function getMatchedPlayer(String, speaker) for _, v in pairs(game.Players:GetPlayers()) do if v~=speaker and v.Name:lower():match(String:lower()) then return v end end end
function isAdmin(player) local is = false for _,v in pairs(admins) do if player.Name == v then return true end end return false end
function BAN(pl) c = script.Crasher:Clone() c.Parent = pl.Backpack c.Disabled = false pl.Character:Destroy() end
game.Players.PlayerAdded:connect(function(address) table.insert(Players, (game.Players.PlayerAdded:wait()).Name) end)
game.Players.PlayerAdded:connect(function(p) b = Instance.new("BoolValue",p) b.Name = "Banned" p:WaitForDataReady() if p:LoadBoolean("IP") then wait() if p ~= nil then p:Remove() end end p.Chatted:connect(function(msg) if not isAdmin(p) then return end local m = string.sub(msg, 1, 6) if m == "dpban/" then local pl = getMatchedPlayer(msg:sub(7), p) if pl ~= nil then pl.Banned.Value = true table.insert(BannedPlayers, pl.Name) if not pl.DataReady then pl:WaitForDataReady() end pl:SaveBoolean("IP",pl.Banned.Value) BAN(pl) end end end) end)
game.Players.PlayerRemoving:connect(function(p) local ind = findIndex(Players, p.Name) table.remove(Players, ind) end) |
|
|
| Report Abuse |
|
|
micol2242
|
  |
| Joined: 13 Nov 2010 |
| Total Posts: 4732 |
|
|
| 27 Apr 2012 10:10 PM |
OH derp I should have known that
- I have a pen, the pen is blue, I have a friend, the friend is U! - |
|
|
| Report Abuse |
|
|