Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using GTANetworkAPI;
- using System.Threading.Tasks;
- using MySql.Data.MySqlClient;
- namespace ServerSide.Client
- {
- public class Data
- {
- public static readonly String DataIdentifier = "PlayerInfo";
- public Player PlayerData { get; set; }
- public String Name { get; set; }
- public int SQLID { get; set; }
- public string Password { get; set; }
- public string Email { get; set; }
- public string SocialClub { get; set; }
- public ulong SocialClubID { get; set; }
- public string LastIP { get; set; }
- public int ID { get; set; }
- public int SessionID { get; set; }
- public int Cash { get; set; }
- public int BankCash { get; set; }
- public int Gold { get; set; }
- public int Level { get; set; }
- public int EXP { get; set; }
- public int Age { get; set; }
- public double PhoneNumber { get; set; }
- public int Health { get; set; }
- public int Hunger { get; set; }
- public int Thirst { get; set; }
- public int Armor { get; set; }
- public int Job { get; set; }
- public int Faction { get; set; }
- public int FactionRank { get; set; }
- public bool isNewbie { get; set; }
- public bool isArrested { get; set; }
- public int ArrestTime { get; set; }
- public bool isBanned { get; set; }
- public int BanTime { get; set; }
- public bool isMuted { get; set; }
- public int MuteTime { get; set; }
- public bool IsLoggedIn { get; set; }
- public bool Withelist { get; set; }
- public Data(Player player)
- {
- this.PlayerData = player;
- this.Name = player.Name;
- this.SQLID = 0;
- this.Password = null;
- this.Email = null;
- this.SocialClub = player.SocialClubName;
- this.SocialClubID = player.SocialClubId;
- this.LastIP = player.Address;
- this.ID = 0;
- this.SessionID = 0;
- this.Cash = 5000;
- this.BankCash = 10000;
- this.Gold = 0;
- this.Level = 0;
- this.EXP = 0;
- this.Age = 18;
- this.PhoneNumber = 0;
- this.Health = 0;
- this.Hunger = 100;
- this.Thirst = 100;
- this.Armor = 0;
- this.Job = 0;
- this.Faction = 0;
- this.FactionRank = 0;
- this.isNewbie = true;
- this.isArrested = false;
- this.ArrestTime = 0;
- this.isBanned = false;
- this.BanTime = 0;
- this.isMuted = false;
- this.MuteTime = 0;
- this.IsLoggedIn = false;
- this.Withelist = false;
- }
- public void SetHealth(int health)
- {
- this.Health = health;
- this.PlayerData.Health = health;
- }
- public static Data GetDataFromPlayer(Player player)
- {
- if (player == null)
- return null;
- if (player.HasData(DataIdentifier))
- {
- return player.GetData<Data>(DataIdentifier);
- }
- else
- {
- Data tmp = new Data(player);
- player.SetData(DataIdentifier, tmp);
- return player.GetData<Data>(DataIdentifier);
- }
- }
- public async Task<bool> AccountExists()
- {
- String Query = $"SELECT COUNT(*) AS AccNo FROM `accounts` WHERE `Playername` = @Playername LIMIT 1;";
- bool accountExists = false;
- using (MySqlCommand command = new MySqlCommand(Query, mysql.MySQL.conn))
- {
- command.Parameters.AddWithValue("@Playername", this.PlayerData.Name);
- using (var reader = await command.ExecuteReaderAsync())
- {
- if (await reader.ReadAsync())
- {
- if (Convert.ToInt32(reader["AccNo"]) == 1)
- accountExists = true;
- else
- accountExists = false;
- }
- }
- }
- return accountExists;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement