pejczi Posted July 20, 2013 Share Posted July 20, 2013 function unBanAll ( source, command ) if ( hasObjectPermissionTo ( source , "function.removeBan", false ) ) then local bans = getBans() for i,d in ipairs ( bans ) do local nick = getBanNick (d) if (removeBan(d) ) then outputChatBox ("All players has been successfully unbanned using Pejczi's script !" , source) else outPutChatBox ( " You have no permission to unban all" , source ) end end table.getn ( bans ) if #bans == 0 then outputChatBox ("No players to unban!") end end end addCommandHandler ("unbanall", unBanAll) It shows as many "All players has been successfully unbanned using Pejczi's script " outputs, as there are bans , cause it's in the loop - the problem is i have no idea how to put it out of the loop. Second problem is it doesn't show "You have no permission to unban all" - it shows correctly "No players to unban" when table is empty. Any ideas ? Link to comment
WASSIm. Posted July 20, 2013 Share Posted July 20, 2013 function unBanAll ( source, command ) if ( hasObjectPermissionTo ( source , "function.removeBan", true ) ) then local bans = getBans() for i,d in ipairs ( bans ) do removeBan(d) if (removeBan(d) ) then outputChatBox ("All players has been successfully unbanned using Pejczi's script !" , source) else outputChatBox ( " You have no permission to unban all" , source ) end end else outputChatBox ("No players to unban!" , source) end end addCommandHandler ("unbanall", unBanAll) Link to comment
pejczi Posted July 20, 2013 Author Share Posted July 20, 2013 Doesn't output any message when i'm logged in and table is clear, when i'm not logged in ,it outputs "No players to unban!". And still " outputChatBox ("All players has been successfully unbanned using Pejczi's script !" , source)" is in loop. bans = {} function unBanAll ( source, command ) if ( hasObjectPermissionTo ( source , "function.removeBan", true ) ) then local bans = getBans() for i,d in ipairs ( bans ) do removeBan(d) if (removeBan(d) ) then outputChatBox ("All players has been successfully unbanned using Pejczi's script !" , source) else outputChatBox ( " You have no permission to unban all" , source ) end end else table.getn ( bans ) if #bans == 0 then outputChatBox ("No players to unban!" , source) end end end addCommandHandler ("unbanall", unBanAll) Added table, but still ain't work. Link to comment
denny199 Posted July 20, 2013 Share Posted July 20, 2013 use https://wiki.multitheftauto.com/wiki/GetBanNick Link to comment
pejczi Posted July 20, 2013 Author Share Posted July 20, 2013 usehttps://wiki.multitheftauto.com/wiki/GetBanNick But why? I don't want to get any nick ;o Link to comment
Moderators IIYAMA Posted July 20, 2013 Moderators Share Posted July 20, 2013 function unBanAll ( source, command ) if ( hasObjectPermissionTo ( source , "function.removeBan", true ) ) then local bans = getBans() if #bans == 0 then outputChatBox ("No players to unban!" , source) else local failedUnbans = 0 for i,ban in pairs ( bans ) do if not removeBan(ban) then failedUnbans = failedUnbans+1 end end if failedUnbans == 0 then outputChatBox ("All players has been successfully unbanned using Pejczi's script !" , source) else outputChatBox ("Failed to unban: " .. failedUnbans .. " bans.", source) end end else outputChatBox ( "You have no permission to unban all." , source ) end end addCommandHandler ("unbanall", unBanAll) Learn lua.... ftw Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now