antiblock
Rodnia | Alpha & Omega
  • Chatbox

    Did you check out our Discord? https://discord.gg/FFdvMjk9xA
    You don't have permission to chat.
    Load More
Sign in to follow this  
douglasld

Quest-Contador De Players Online!

18 posts in this topic

local lines = {}
for line in io.read("usage.txt") do
    table.insert(lines, line)
end
local currentData = lines[table.getn(lines)]
if not currentData or currentData == "" then
    currentData = lines[table.getn(lines)-1]
end

local tokens = string.split(currentData, "|") -- {string.match(currentData, (string.gsub(currentData, "[^|]*|", "([^|]*)|")))}
local averageVal = tonumber(tokens[3])
local maxVal = tonumber(tokens[4])

say("Em média há "..averageVal.." jogadores conectados.")
say("No máximo houve "..maxVal.." jogadores conectados.")

Salvo erro a lua 5.0 tem a função string.match(). Se não tiver basta usar esta função:

function string:split(inSplitPattern, outResults)
   if not outResults then
      outResults = {}
   end
   local theStart = 1
   local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
   while theSplitStart do
      table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
      theStart = theSplitEnd + 1
      theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
   end
   table.insert( outResults, string.sub( self, theStart ) )
   return outResults
end

Share this post


Link to post
Share on other sites
antiblock
Elveron

queria uma quest para quando todos os jogadores entrassem no jogo tivesse uma missão que ao clicar nela saberia quantas pesssoas estão online no servidor, tipo o comando /w de gm

xD

Share this post


Link to post
Share on other sites

must start with 'quest'
online_count.quest:1:Abort (core dumped)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this