Player stats list
#1
Hello, I need to make a little database with this information:

Player name
Killed mobs
Destroyed Blocks
Died
etc.

If its possible on mc-server?
Reply
Thanks given by:
#2
There are hooks for all of those events and SQLite bindings to store the data so it should be possible.
Reply
Thanks given by:
#3
Can you write a little example? i am a novice in lua
Reply
Thanks given by:
#4
I'm afraid I'm the wrong person to ask, I know the API from the c++ side, so I know very little about lua as well.
Reply
Thanks given by:
#5
crap. i am too :-( Relly MC-Server Nice platform for server. but plugins...
Reply
Thanks given by:
#6
Have a look at the documentation page, it has a few examples, too, in the Articles section:
http://mc-server.xoft.cz/LuaAPI/
Reply
Thanks given by:
#7
:-( I do not quite understand programming. I need an example of writing to a text file number of broken blocks. Please help, it is very necessary
Reply
Thanks given by:
#8
Well, if you wanna write to a .ini file (basically a fancy text file), here's some basic functions:

-- File path, the root starts at the MCServer executable
local FilePath = "Plugins/SomePlugin/MyIniFile.ini"

-- An integer that we want to store, let's say 34
local BlocksDestroyed = 34

-- Creates a .ini file object
local SomeIniFile = cIniFile()

-- Create a key for values to go under
SomeIniFile:AddKeyName("BlocksBroken")

-- Create a value under this key name
SomeIniFile:SetValueI("BlocksBroken", "ValueNumber", BlocksDestroyed)

-- Write the file to disk
SomeIniFile:WriteFile(FilePath)

If you would like to access that value from disk, do this:

-- Read the file off of the disk
SomeIniFile:ReadFile(FilePath)

-- Set value of NumBlocks to the amount stored under the key name and that specific value name
local NumBlocks = SomeIniFile:GetValueI("BlocksBroken", "ValueNumber")
file
NumBlocks would then contain the 34 that was stored in the file earlier. If you look in the file at the set file path, you should see a file structured like this:

[BlocksBroken]
ValueNumber=34

Hope this might have helped.
Reply
Thanks given by:
#9
@DiamondToaster But that isn't per-player right?
Reply
Thanks given by:
#10
Well, that was just an example of how it worked.

Per-player, I would do something like this:

-- Assuming the blocks broken is 34 or something like that...
local BlocksBroken = 34

-- If the player's key name does not exist, add it
if SomeIniFile:FindKey(Player:GetUUID()) == -1 then
    SomeIniFile:AddKeyName(Player:GetUUID())
end

-- Write the amount of blocks broken under the 'BlocksBroken' value under the Player's UUID
SomeIniFile:SetValueI(Player:GetUUID(), "BlocksBroken", BlocksBroken)

-- Write the file to disk
SomeIniFile:WriteFile(FilePath)

And to access it:
-- Read the file off of the disk
SomeIniFile:ReadFile(FilePath)
 
-- Set value of NumBlocks to the amount stored under the Player's key name and 'BlocksBroken' value name
local NumBlocks = SomeIniFile:GetValueI(Player:GetUUID(), "BlocksBroken")
Reply
Thanks given by:




Users browsing this thread: 3 Guest(s)