GrubaS Posted July 25, 2015 Share Posted July 25, 2015 (edited) fixed Edited July 25, 2015 by Guest Link to comment
GTX Posted July 25, 2015 Share Posted July 25, 2015 What specifically doesn't work? Any errors in debug script? function ban(p,_,player) local player = getPlayerWildcard(player)[1] local accName = getAccountName(getPlayerAccount(player)) if not isObjectInACLGroup("user."..accName,aclGetGroup'Admin') then return outputChatBox("Error: You are not an Admin.",p,255,0,0) end if not player then return outputChatBox("Error: usage /ban ",p,255,0,0) end local table = getPlayerWildcard(player) if #table == 0 then return outputChatBox ( "Error: '"..player.."' matches no players.",p,255,0,0) end if #table == 1 then return outputChatBox ( removeColor( getPlayerName( table[1] ) ).." has been banned by "..removeColor(getPlayerName(p)),root,255,0,0) banPlayer(player,false,false,true,p) end outputChatBox("Error: '"..player.."' matches "..#table.." players.",p,255,0,0) end addCommandHandler("ban",ban) function removeColor(string) return string.gsub(string,"#%x%x%x%x%x%x","") end function getPlayerWildcard ( string ) local player = getPlayerFromName ( string ) if ( player ) then return player end local matches = {} for id, player in ipairs ( getElementsByType ( "player" ) ) do if ( string.find ( string.upper ( getPlayerName ( player ) ), string.upper ( string ), 1, true ) ) then table.insert(matches,player) end end return #matches end Link to comment
Perfect Posted July 25, 2015 Share Posted July 25, 2015 As GTX stated, we don't know what is the problem. I fix what I think was wrong. Try this one as well. function ban(p,_,player) local accName = getAccountName(getPlayerAccount(p)) if not isObjectInACLGroup("user."..accName,aclGetGroup'Admin') then return outputChatBox("Error: You are not an Admin.",p,255,0,0) end if not player then return outputChatBox("Error: usage /ban ",p,255,0,0) end local table = getPlayerWildcard(player) if #table == 0 then return outputChatBox ( "Error: '"..player.."' matches no players.",p,255,0,0) end if #table == 1 then return outputChatBox ( removeColor( getPlayerName( table[1] ) ).." has been banned by "..removeColor(getPlayerName(p)),root,255,0,0) banPlayer(player,false,false,true,p) end outputChatBox("Error: '"..player.."' matches "..#table.." players.",p,255,0,0) end addCommandHandler("ban",ban) function removeColor(string) return string.gsub(string,"#%x%x%x%x%x%x","") end function getPlayerWildcard ( string ) local player = getPlayerFromName ( string ) if ( player ) then return player end local matches = {} for id, player in ipairs ( getElementsByType ( "player" ) ) do if ( string.find ( string.upper ( getPlayerName ( player ) ), string.upper ( string ), 1, true ) ) then table.insert(matches,player) end end return #matches end Link to comment
GrubaS Posted July 25, 2015 Author Share Posted July 25, 2015 debug: " 'end' expected near 'banPlayer' " Link to comment
GrubaS Posted July 25, 2015 Author Share Posted July 25, 2015 debug: " 'end' expected near 'banPlayer' " OMG I WANTED EDIT THIS POST!@)#$_!@#)!@#_@!#_@)_!)#_!@)#!@_#) Link to comment
Perfect Posted July 25, 2015 Share Posted July 25, 2015 If I am right, anything after the 'return' will not execute. In your script, banPlayer function was after the 'return' which made it unable to execute. I also have indented your code which will make it easier to read. function ban(p,_,player) local accName = getAccountName(getPlayerAccount(p)) if not isObjectInACLGroup("user."..accName,aclGetGroup'Admin') then return outputChatBox("Error: You are not an Admin.",p,255,0,0) end if not player then return outputChatBox("Error: usage /ban ",p,255,0,0) end local table = getPlayerWildcard(player) if #table == 0 then return outputChatBox ( "Error: '"..player.."' matches no players.",p,255,0,0) end if #table == 1 then outputChatBox ( removeColor( getPlayerName( table[1] ) ).." has been banned by "..removeColor(getPlayerName(p)),root,255,0,0) banPlayer(player,false,false,true,p) end outputChatBox("Error: '"..player.."' matches "..#table.." players.",p,255,0,0) end addCommandHandler("ban",ban) function removeColor(string) return string.gsub(string,"#%x%x%x%x%x%x","") end function getPlayerWildcard ( string ) local player = getPlayerFromName ( string ) if ( player ) then return player end local matches = {} for id, player in ipairs ( getElementsByType ( "player" ) ) do if ( string.find ( string.upper ( getPlayerName ( player ) ), string.upper ( string ), 1, true ) ) then table.insert(matches,player) end end return #matches end 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