zMpyster Posted February 19, 2019 Share Posted February 19, 2019 Não está tendo erro o script só estou com medo de que quando entre bastante pessoas bug ent resolvi pedir algumas sugestões e opiniões function Init () if ( getResourceFromName ( "scoreboard" ) and getResourceState ( getResourceFromName ( "scoreboard" ) ) == "running" ) then scoreboard = exports.scoreboard _dxver = false elseif ( getResourceFromName ( "dxscoreboard" ) and getResourceState ( getResourceFromName ( "dxscoreboard" ) ) == "running" ) then scoreboard = exports.dxscoreboard _dxver = true else outputDebugString ( "No scoreboard resource has been started", 2 ) _initp = false end if _initp then scoreboard:addScoreboardColumn ( "ID", getRootElement(), 1, 0.05 ) -- Add the ID column sortScoreboard( "ID" ) end if not _loaded then loadID() end end addEventHandler ( "onResourceStart", resourceRoot, Init ) function loadID () _loaded = true for _, player in ipairs ( getElementsByType ( "player" ) ) do assignPlayerID ( player ) end end function assignPlayerID ( player ) local acc = getPlayerAccount(player) if getAccountData(acc, "ID") then local IDdeQuemJaTem = getAccountData(acc, "ID") return setElementData(player, "ID", IDdeQuemJaTem) else local chorID = nil local chorID = math.random(1,999) if isIDAvailable ( chorID, player ) == true then setElementData ( player, "ID", chorID ) sortScoreboard( "ID" ) availableID[ chorID ] = false else end end end n = {} function isIDAvailable ( id, player ) local accs = getAccounts() for i, accounts in ipairs(accs) do if getAccountData(accounts, "ID") then local idNew = getAccountData(accounts, "ID") if idNew == id then n[player] = false break else n[player] = true end else n[player] = true end end if n[player] == true then return true else assignPlayerID(player) return false end end function onLeave () local acc = getPlayerAccount(source) local s_id = getElementData ( source, "ID" ) or getAccountData(acc, "ID") availableID[ s_id ] = false setAccountData(acc, "ID", s_id) end addEventHandler ( "onPlayerQuit", getRootElement(), onLeave ) function onLogin (_, c) assignPlayerID(source) end addEventHandler ( "onPlayerLogin", getRootElement(), onLogin ) Link to comment
#DaNiLiN Posted February 19, 2019 Share Posted February 19, 2019 (edited) Há um tempo DNL Me orientou a montar um usando getAccountID, No caso transformei ele em ElementData e claro ficou bem mais curto deve ser útil para você.http://megamodsmtasa.blogspot.com/2019/02/idpermanente-sem-bugs.html Edited February 19, 2019 by #DaNiLiN 1 Link to comment
zMpyster Posted February 19, 2019 Author Share Posted February 19, 2019 4 minutes ago, #DaNiLiN said: Há um tempo DNL Me orientou a montar um usando getAccountID, No caso transformei ele em ElementData e claro ficou bem mais curto deve ser útil para você.http://megamodsmtasa.blogspot.com/2019/02/idpermanente-sem-bugs.html Só pra desencargo de consciência, você achou algum erro Link to comment
#DaNiLiN Posted February 19, 2019 Share Posted February 19, 2019 Bom, Acho que não, Não li o código. Mas se ta funfando... é sinal que não tem bug 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