SteeLRO Posted February 26, 2014 Share Posted February 26, 2014 clanPlayers[] = { "3R//", "Name2", "Name3" } local colorCodeRed[] = {255,0,0} local colorCodeGreen[] = {0,255,0} local colorCodeBlue[] = {0,0,255} setTimer(function() if isInClan(source) == true then setPlayerName(source,"3R//"..getPlayerName(source)) end end,1000,0) function isInClan(player) local name = getPlayerName(player) for i,v in ipairs (clanPlayers) do if name == clanPlayers[1] then return true end end return false end Link to comment
WhoAmI Posted February 26, 2014 Share Posted February 26, 2014 I'm not sure, but this "[]" isn't needed at all. clanPlayers = { "3R//", "Name2", "Name3" } local colorCodeRed = {255,0,0} local colorCodeGreen = {0,255,0} local colorCodeBlue = {0,0,255} setTimer(function() if isInClan(source) == true then setPlayerName(source,"3R//"..getPlayerName(source)) end end,1000,0) function isInClan(player) local name = getPlayerName(player) for i,v in ipairs (clanPlayers) do if name == clanPlayers[1] then return true else return false end end end Link to comment
pa3ck Posted February 26, 2014 Share Posted February 26, 2014 The function is not attached to an event, 'source' in the timer is going to return nil. Also, use string.find in the name, because it's just a tag, not the whole name of the player. Link to comment
SteeLRO Posted February 26, 2014 Author Share Posted February 26, 2014 I can do you right I do not understand Link to comment
pa3ck Posted February 26, 2014 Share Posted February 26, 2014 I don't understand you neither. 'I can do you right' what you mean by that? That sounds perv tho... Link to comment
Moderators Citizen Posted February 26, 2014 Moderators Share Posted February 26, 2014 clanPlayers[] = { "3R//", "Name2", "Name3" } local colorCodeRed[] = {255,0,0} local colorCodeGreen[] = {0,255,0} local colorCodeBlue[] = {0,0,255} setTimer(function() if isInClan(source) == true then setPlayerName(source,"3R//"..getPlayerName(source)) end end,1000,0) function isInClan(player) local name = getPlayerName(player) for i,v in ipairs (clanPlayers) do if name == clanPlayers[1] then return true end end return false end Ok lol so first, it's not a proper way to ask help to a community ... For me it's just like if you threw your dirty clothes on your mom face to make her wash them. You would never do that so it's the same here. It's really disrespectfull. Even if you don't speak in english well, it's easy to say something like: "Hello everyone, I have a problem with my code. I want to add the clantag "3R//" to the players in my list if they don't have it yet. Here is the code:" And only after said that you can paste your code between lua tags and also give us the errors from the server console or from /debugscript 3 (you need to be logged in) if there are any. That said, I saw your script and I think I understood what you were trying to do. So here is it: local clanTag = "3R//" local clanPlayers = { "Name1", "Name2", "Name3" } local colorCodeRed = {255, 0, 0} local colorCodeGreen = {0, 255, 0} local colorCodeBlue = {0, 0, 255} setTimer(function() for k, player in ipairs (getElementsByType("player")) do if isInClan(player) and not hasClanTag(player) then setPlayerName(player, clanTag..getPlayerName(player)) end end end, 5000, 0) function hasClanTag(player) local name = getPlayerName(player) if name and string.find(name, clanTag) then return true end return false end function isInClan(player) local name = getPlayerName(player) or "" for i, v in ipairs (clanPlayers) do if name == clanPlayers[i] then return true end end return false 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