I was thinking about adding the ability for some "trusty" players to use the command /addplayertoarea.
To keep things easier two new command("legit to use by NOT admins") like /addplayer and /removeplayer< followed by the name of the friendly player should be added.
Problem is.. with this commands(which are "copies" of the admin-commands /addplayertoarea and /removeplayerfromarea) any player could add players to foreign areas..
So a check has to be included to be sure the player who uses the new commands is the "admin" of the area.
Now I noticed I really dont get the db-stuff thing..
local area = getCurrentArea(event.chunkOffsetX, event.chunkOffsetY, event.chunkOffsetZ, event.blockPositionX, event.blockPositionY, event.blockPositionZ);
local group = getPlayerGroupInArea(event.player, area);
if group["PlaceBlock"] == false then
event.player:sendTextMessage("[#FF0000]"This is not YOUR area..");
* add or remove another player like in the /addplayer or /removeplayer section *
Well, I dont even know IF there has to be those ";" after the sendTextMessage.. or if I have to RETURN it?
A closer look at the db showed the following:
Hint for linux users: you may install sqlite3 to be able to look into the *.db files using the midnightcommander
CREATE TABLE 'areas' ('ID' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'name' VARCHAR, .. , 'playerID' INTEGER);
INSERT INTO "areas" VALUES(3,'Spawn',15,1,15,5,40,5,16,1,16,9,54,8,1);
As described in the table the first value is the "index"(3), so I had already created and removed the "Spawn" area two times.
The last number is the "player ID"(1). Okay, I was the first who joined the server so I assume number "1" belongs to me.
As ALL areas have the same player ID (1) it shows who created the area. Not who "owns" it!
Big question: How to get the real player names behind the player IDs?
In the world folder there should be another *.db which contains the following:
CREATE TABLE 'Player' ('ID' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'Name' VARCHAR(30),
INSERT INTO "Player" VALUES(1,'DHLF','..
Here are all players stored which ever connected to the server.
And a last look into the /AreaProtection.db:
INSERT INTO "rights" VALUES(10,3,1,'Admin');
10 is the index number, 3 targets the above "Spawn" area and 1 belongs to player DHLF. Admin tells DHLF is the "Owner/Admin" of that area.
Theoratically I just have to do the following:
get the 'playerID' of the area in which the player is standing, check if those 'playerID' matches those of the player who commanded /addplayer AND if he is "ADMIN".
This seems to be tricky as more people could be already at least "owner" of those area..
We have to be sure not to focus on the first entry alone..