12345678910111213141516171819202122232425262728293031323334353637 |
- event.load("player_login");
- event.load("player_logout");
- executeOnce = databank.prepare("CREATE TABLE IF NOT EXISTS playtime (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, player_id INT NOT NULL, join_time BIGINT NOT NULL, leave_time BIGINT);");
- databank.workerExecute(executeOnce);
- msg("dev", "§bPlaytime §rloaded.");
- @wait
- wait();
- player_id = player.getId(player);
- igoto(event);
- goto("wait");
- @player_login
- deleteInvalidStatement = databank.prepare("DELETE FROM playtime WHERE player_id = ? AND leave_time IS NULL;", false);
- databank.setInt(deleteInvalidStatement, 1, player_id);
- databank.workerExecute(deleteInvalidStatement);
- joinTimeStatement = databank.prepare("INSERT INTO playtime (player_id, join_time) VALUES (?, ?);", false);
- databank.setInt(joinTimeStatement, 1, player_id);
- databank.setLong(joinTimeStatement, 2, time.getMillis());
- databank.workerExecute(joinTimeStatement);
- goto("wait");
- @player_logout
- leaveTimeStatement = databank.prepare("UPDATE playtime SET leave_time = ? WHERE player_id = ? AND leave_time IS NULL;", false);
- databank.setLong(leaveTimeStatement, 1, time.getMillis());
- databank.setInt(leaveTimeStatement, 2, player_id);
- databank.workerExecute(leaveTimeStatement);
- //Leavetime für /seen und /lastseen
- nowtime = time.getMillis();
- timeStatement = databank.prepare("INSERT INTO logoutdata (player_id,logouttime) SELECT ?, ? ON DUPLICATE KEY UPDATE logoutdata.logouttime=?;", false);
- databank.setInt(timeStatement, 1, player.getID(player));
- databank.setLong(timeStatement, 2, nowtime);
- databank.setLong(timeStatement, 3, nowtime);
- databank.workerExecute(timeStatement);
- goto("wait");
|