Arantes Posted May 24, 2020 Posted May 24, 2020 Gostaria de fazer uma verificação que, quando o jogador colocasse seu nome no painel , verificava se ja existe e retornava com um aviso . local nick = getElementData ( localPlayer , "playername" ) if (nick == false) then -- REGISTRAR else outputChatBox("Nome existente !") end
Other Languages Moderators Lord Henry Posted May 24, 2020 Other Languages Moderators Posted May 24, 2020 function haveOtherNick (myName) for i, player in ipairs (getElementsByType("player")) do if (getElementData (player, "playername") and getElementData (player, "playername") == myName) then return true end end return false end -- Exemplo: addCommandHandler ("teste", function (cmd) local nome = getElementData (localPlayer, "playername") if (nome) then if (haveOtherNick(nome)) then outputChatBox ("Já tem alguém com esse nome online.") end else -- Registro. end end Se quiser fazer com accountData, terá que fazer server-side. 1
Arantes Posted May 25, 2020 Author Posted May 25, 2020 Entendi muito obrigado , mas seria possivel fazer algo assim ? local nome = getElementData (localPlayer, "playername") if guiGetText(NickBoxText) == (haveOtherNick(nome)) then outputChatBox ("Já tem alguém com esse nome online.") return end -- Onde esta setando o nome. SetNickBoxText = guiGetText(NickBoxText) setElementData ( localPlayer, "playername", ""..SetNickBoxText.."" )
DNL291 Posted May 25, 2020 Posted May 25, 2020 getPlayerName já retorna o nick do joagdor, não precisa salvar em elementData. @Arantes faça com esta lógica: local NickBoxText = guiCreateEdit(...) local vNick = guiGetText(NickBoxText) if (haveOtherNick(vNick)) then outputChatBox ("Já tem alguém com esse nome online.") else setElementData ( localPlayer, "playername", vNick ) end 1
Arantes Posted May 25, 2020 Author Posted May 25, 2020 Sim sim é verdade, mas o código define o nick do jogador fixo, ai por isso estou salvando em elementData. Obrigado pela ajuda , mas a verificação esta passando direto , consigo salvar o mesmo nome que alguém tenha em seu playername.
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