protected virtual void HookEventHandlers() { OnLevelUnloadEvent.Register(HandleLevelUnload, Priority.High); OnSendingHeartbeatEvent.Register(HandleSendingHeartbeat, Priority.High); OnSQLSaveEvent.Register(SaveStats, Priority.High); OnPlayerActionEvent.Register(HandlePlayerAction, Priority.High); OnPlayerDisconnectEvent.Register(HandlePlayerDisconnect, Priority.High); }
protected virtual void UnhookEventHandlers() { OnLevelUnloadEvent.Unregister(HandleLevelUnload); OnSendingHeartbeatEvent.Unregister(HandleSendingHeartbeat); OnSQLSaveEvent.Unregister(SaveStats); OnPlayerActionEvent.Unregister(HandlePlayerAction); OnPlayerDisconnectEvent.Unregister(HandlePlayerDisconnect); }
public void save() { OnSQLSaveEvent.Call(this); if (cancelmysql) { cancelmysql = false; return; } // Player disconnected before SQL data was retrieved if (!gotSQLData) { return; } long blocks = PlayerData.Pack(TotalPlaced, TotalModified); long drawn = PlayerData.Pack(TotalDeleted, TotalDrawn); Database.UpdateRows("Players", "IP=@0, LastLogin=@1, totalLogin=@2, totalDeaths=@3, Money=@4, " + "totalBlocks=@5, totalCuboided=@6, totalKicked=@7, TimeSpent=@8, Messages=@9", "WHERE Name=@10", ip, LastLogin.ToString(Database.DateFormat), TimesVisited, TimesDied, money, blocks, drawn, TimesBeenKicked, (long)TotalTime.TotalSeconds, TotalMessagesSent, name); }