Flipi Posted May 20, 2014 Share Posted May 20, 2014 Hi guys, How I create a script to allowing verify if a player belongs to the team, else the player is kicked?. Example: Juan changed the nick to "(lel)Juan". ..Verifying the player: "(lel)Juan" in the "LEL" team. The player "(lel)Juan" is kicked for not belongs to the team.. This is my script team, how to add in this script? function createSomethingTeamOnStart () SomethingTeam = createTeam ( "SomethingTeam", 132, 132, 132 ) end addEventHandler("onResourceStart", resourceRoot, createSomethingTeamOnStart) function setSomethingTeam() if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("SomethingTeam")) then setPlayerTeam(source, SomethingTeam) end end addEventHandler("onPlayerLogin",getRootElement(),setSomethingTeam) chualo con nutella Link to comment
.:HyPeX:. Posted May 20, 2014 Share Posted May 20, 2014 Taken out from BOSS's script function CheckNick(cmd, player, nick) local playername0 = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") local playername1 = string.gsub(playername0, "[b]", "b") local playername2 = string.gsub(playername1, "[O]", "o") local playername3 = string.gsub(playername2, "[(SS)]", "ss") local playername4 = string.gsub(playername3, "[s]", "s") if (string.find(playername4,"boss")) then if (isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(source)), aclGetGroup("BOSS"))) then setPlayerTeam(source,Bossteam) outputChatBox("Welcome back " .. nick .. "#FF5555 to BOSS!",source, 231, 106, 12, true) else outputChatBox("#FF5555[Team]: kicked player #ffffff".. getPlayerName(player) .."#FF5555 for trying to fake the team!", getRootElement(), 255, 85, 85, true) kickPlayer(source, "Player with BOSS tag not logged in") end end end addCommandHandler("nick", CheckNick, false, false) Link to comment
Flipi Posted May 20, 2014 Author Share Posted May 20, 2014 Taken out from BOSS's script function CheckNick(cmd, player, nick) local playername0 = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") local playername1 = string.gsub(playername0, "[b]", "b") local playername2 = string.gsub(playername1, "[O]", "o") local playername3 = string.gsub(playername2, "[(SS)]", "ss") local playername4 = string.gsub(playername3, "[s]", "s") if (string.find(playername4,"boss")) then if (isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(source)), aclGetGroup("BOSS"))) then setPlayerTeam(source,Bossteam) outputChatBox("Welcome back " .. nick .. "#FF5555 to BOSS!",source, 231, 106, 12, true) else outputChatBox("#FF5555[Team]: kicked player #ffffff".. getPlayerName(player) .."#FF5555 for trying to fake the team!", getRootElement(), 255, 85, 85, true) kickPlayer(source, "Player with BOSS tag not logged in") end end end addCommandHandler("nick", CheckNick, false, false) This is the tag of team? local playername1 = string.gsub(playername0, "[b]", "b") local playername2 = string.gsub(playername1, "[O]", "o") local playername3 = string.gsub(playername2, "[(SS)]", "ss") local playername4 = string.gsub(playername3, "[s]", "s") if (string.find(playername4,"boss")) then Link to comment
MIKI785 Posted May 20, 2014 Share Posted May 20, 2014 local playername1 = string.gsub(playername0, "[b]", "b") local playername2 = string.gsub(playername1, "[O]", "o") local playername3 = string.gsub(playername2, "[(SS)]", "ss") local playername4 = string.gsub(playername3, "[s]", "s") if (string.find(playername4,"boss")) then That's just... wrong... You should just simply check for the tag in the last line, that is: if (string.find(playername,"%[tag%]")) then % are used because [ and ] are "magical" characters. Link to comment
.:HyPeX:. Posted May 20, 2014 Share Posted May 20, 2014 I just check the lowercase of the name, its an outdated version, nowdays i'd do this: local playername1 = string.lower(playername0) if (string.find(playername1,"boss")) then Link to comment
Flipi Posted May 21, 2014 Author Share Posted May 21, 2014 but which would be more optimized? this?: local playername1 = string.lower(playername0) if (string.find(playername1,"go!")) then or this?: if (string.find(playername,"%go%!")) then PD: "go!" is a example of any tag. Link to comment
.:HyPeX:. Posted May 21, 2014 Share Posted May 21, 2014 Im not sure that the % one will work, mine will work perfectly. (Already tested it) Link to comment
Flipi Posted May 21, 2014 Author Share Posted May 21, 2014 Im not sure that the % one will work, mine will work perfectly. (Already tested it) ahh ok, I'll test thanks c: 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