Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using GTANetworkAPI;
- using System.Threading;
- using System.Threading.Tasks;
- using MySql.Data.MySqlClient;
- namespace One_V.Player
- {
- class Data
- {
- public static readonly String DataIndentifier = "PlayerInfo";
- public Client PlayerData { get; set; }
- public String Name { get; set; }
- public int Cash { get; set; }
- public int Level { get; set; }
- public int Age { get; set; }
- public int Health { get; set; }
- public Data(Client player)
- {
- this.PlayerData = player;
- this.Name = player.Name;
- this.Cash = 0;
- this.Level = 0;
- this.Age = 0;
- this.Health = 0;
- }
- public void SetHealth(int health)
- {
- this.Health = health;
- this.PlayerData.Health = health;
- }
- public static Data GetDataFromClient(Client player)
- {
- if(player == null)
- return null;
- if (player.HasData(DataIndentifier))
- {
- return player.GetData(DataIndentifier);
- }
- else
- {
- Data tmp = new Data(player);
- player.SetData(DataIndentifier, tmp);
- return tmp;
- }
- }
- public async Task<bool> AccountExists()
- {
- String Query = $"SELECT COUNT(*) AS AccNo FROM `accounts` WHERE `Playername` = @Playername LIMIT 1;";
- 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)
- return true;
- }
- }
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement