public static TLPlayerStats GetPlayerStats(Client client) { TLMongoDatabase db = new TLMongoDatabase(); if (!client.HasData("ID")) { return(null); } TLPlayerStats playerStats; ObjectId client_id = client.GetData("ID"); var query = db.GetListById <TLPlayerStats>(client_id).Result; if (query.Count == 0) { playerStats = new TLPlayerStats(); playerStats.Id = client_id; db.Insert <TLPlayerStats>(playerStats); } else { playerStats = query[0]; } return(playerStats); }
public static void FinishLogin(Client client) { TLMongoDatabase db = new TLMongoDatabase(); ObjectId client_id = client.GetData("ID"); TLPlayerStats playerStats; var query = db.GetListById <TLPlayerStats>(client_id).Result; if (query.Count == 0) { playerStats = new TLPlayerStats(); playerStats.Id = client_id; db.Insert <TLPlayerStats>(playerStats); } else { playerStats = query[0]; } client.Position = playerStats.GetLastPosition(); NAPI.Entity.SetEntityTransparency(client, 255); NAPI.Entity.SetEntityInvincible(client, false); NAPI.ClientEvent.TriggerClientEvent(client, "playerLoggedIn"); NAPI.ClientEvent.TriggerClientEvent(client, "LoginResult", 1); NAPI.ClientEvent.TriggerClientEvent(client, "moveSkyCamera", client, "down", 1, true); UpdateMoneyEvent.Update_Money(client); }
public void Event_OnPlayerRegisterAttemptAsync(Client client, object[] arguments) { string username = (string)arguments[0]; string password = (string)arguments[1]; TLPlayer player = new TLPlayer(username, password, client.Name); var isNewUser = db.GetList <TLPlayer>("username", username).Result; if (isNewUser.Count > 0) { client.SendChatMessage("~r~That username already exists"); return; } db.Insert <TLPlayer>(player); client.SendChatMessage("You have been registered"); }
public void EVENT_ResourceStart() { // Load World Defaults var world = db.GetList <TLWorldInfo>().Result; TLWorldInfo worldSettings = new TLWorldInfo(); if (world.Count == 0) { db.Insert <TLWorldInfo>(worldSettings); } else { worldSettings = world[0]; } worldSettings.LoadDefaultWeather(); worldSettings.LoadDefaultTime(); }