326 lines
16 KiB
C#
326 lines
16 KiB
C#
using System;
|
|
using MySql.Data.MySqlClient;
|
|
using GrandTheftMultiplayer.Server;
|
|
using GrandTheftMultiplayer.Shared;
|
|
using GrandTheftMultiplayer.Server.API;
|
|
using GrandTheftMultiplayer.Shared.Math;
|
|
using GrandTheftMultiplayer.Server.Elements;
|
|
using GrandTheftMultiplayer.Server.Constant;
|
|
using GrandTheftMultiplayer.Server.Managers;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Roleplay.Database
|
|
{
|
|
class CharacterDatabase : Script
|
|
{
|
|
public static string myConnectionString = "SERVER=185.223.28.49;" + "DATABASE=gtanetwork;" + "UID=fivem;" + "PASSWORD=" + Main.databasepass + ";";
|
|
public static MySqlConnection connection;
|
|
public static MySqlCommand command;
|
|
public static MySqlDataReader reader;
|
|
public static List<int> femalelegs = new List<int>();
|
|
public static List<int> malelegs = new List<int>();
|
|
public CharacterDatabase()
|
|
{
|
|
femalelegs.Add(0);
|
|
femalelegs.Add(1);
|
|
femalelegs.Add(2);
|
|
femalelegs.Add(3);
|
|
femalelegs.Add(4);
|
|
femalelegs.Add(6);
|
|
femalelegs.Add(7);
|
|
femalelegs.Add(8);
|
|
femalelegs.Add(9);
|
|
femalelegs.Add(10);
|
|
femalelegs.Add(11);
|
|
femalelegs.Add(14);
|
|
femalelegs.Add(16);
|
|
femalelegs.Add(18);
|
|
femalelegs.Add(19);
|
|
femalelegs.Add(23);
|
|
femalelegs.Add(24);
|
|
femalelegs.Add(25);
|
|
femalelegs.Add(27);
|
|
femalelegs.Add(31);
|
|
femalelegs.Add(43);
|
|
femalelegs.Add(44);
|
|
femalelegs.Add(87);
|
|
malelegs.Add(0);
|
|
malelegs.Add(1);
|
|
malelegs.Add(3);
|
|
malelegs.Add(4);
|
|
malelegs.Add(5);
|
|
malelegs.Add(6);
|
|
malelegs.Add(7);
|
|
malelegs.Add(10);
|
|
malelegs.Add(13);
|
|
malelegs.Add(19);
|
|
malelegs.Add(22);
|
|
malelegs.Add(23);
|
|
}
|
|
|
|
|
|
public static class DATABASEFLAGS {
|
|
static public string GTAO_SHAPE_FIRST_ID = "GTAO_SHAPE_FIRST_ID";
|
|
static public string GTAO_SHAPE_SECOND_ID = "GTAO_SHAPE_SECOND_ID";
|
|
static public string GTAO_SHAPE_MIX = "GTAO_SHAPE_MIX";
|
|
static public string GTAO_SKIN_MIX = "GTAO_SKIN_MIX";
|
|
static public string GTAO_HAIR_COLOR = "GTAO_HAIR_COLOR";
|
|
static public string GTAO_EYEBROWS = "GTAO_EYEBROWS";
|
|
static public string GTAO_EYEBROWS_COLOR = "GTAO_EYEBROWS_COLOR";
|
|
static public string GTAO_LIPSTICK = "GTAO_LIPSTICK";
|
|
static public string GTAO_MAKEUP = "GTAO_MAKEUP";
|
|
static public string HAIR = "HAIR";
|
|
static public string TOP = "TOP";
|
|
static public string TOP_COLOR = "TOP_COLOR";
|
|
static public string UNDERSHIRT = "UNDERSHIRT";
|
|
static public string TORSO = "TORSO";
|
|
static public string LEGS = "LEGS";
|
|
static public string LEGS_COLOR = "LEGS_COLOR";
|
|
static public string BAGS = "BAGS";
|
|
static public string FEET = "FEET";
|
|
static public string FEET_COLOR = "FEET_COLOR";
|
|
static public string ACCESSORIES = "ACCESSORIES";
|
|
static public string BODYARMOR = "BODYARMOR";
|
|
}
|
|
|
|
|
|
|
|
// INSERT A CHARACTER IN CHARACTER DATABASE
|
|
public static void insertCharacter(Client player, int geschlecht)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "INSERT INTO `character`(`nickname`, `geschlecht`, `GTAO_SHAPE_FIRST_ID`, `GTAO_SHAPE_SECOND_ID`, `GTAO_SKIN_FIRST_ID`, `GTAO_SKIN_SECOND_ID`, `GTAO_SHAPE_MIX`, `GTAO_SKIN_MIX`, `GTAO_HAIR_COLOR`, `GTAO_HAIR_HIGHLIGHT_COLOR`, `GTAO_EYEBROWS`, `GTAO_EYEBROWS_COLOR`, `GTAO_EYEBROWS_COLOR2`, `GTAO_LIPSTICK`, `GTAO_MAKEUP`, `TORSO`,`UNDERSHIRT`,`TOP`,`TOP_COLOR`, `HAIR`, `HAIR_COLOR`, `LEGS`, `LEGS_COLOR`, `BAGS`, `FEET`, `FEET_COLOR`, `ACCESSORIES`, `BODYARMOR`) VALUES (@nickname,@GESCHLECHT,@GTAO_SHAPE_FIRST_ID,@GTAO_SHAPE_SECOND_ID,@GTAO_SKIN_FIRST_ID,@GTAO_SKIN_SECOND_ID,@GTAO_SHAPE_MIX,@GTAO_SKIN_MIX,@GTAO_HAIR_COLOR,@GTAO_HAIR_HIGHLIGHT_COLOR,@GTAO_EYEBROWS,@GTAO_EYEBROWS_COLOR,@GTAO_EYEBROWS_COLOR2,@GTAO_LIPSTICK,@GTAO_MAKEUP,@TORSO,@UNDERSHIRT,@TOP,@TOP_COLOR,@HAIR,@HAIR_COLOR,@LEGS,1,@BAGS,@FEET,1,@ACCESSORIES,@BODYARMOR)";
|
|
command.Parameters.AddWithValue("@GESCHLECHT", geschlecht);
|
|
command.Parameters.AddWithValue("@nickname", player.name);
|
|
|
|
if (geschlecht == 1) {
|
|
//RANDOMS
|
|
Random rnd = new Random();
|
|
int GTAO_SHAPE_FIRST_ID = rnd.Next(0, 5);
|
|
int GTAO_SHAPE_SECOND_ID = GTAO_SHAPE_FIRST_ID;
|
|
int GTAO_SHAPE_MIX = 100; // HÖHER ALS 50% MÄNNNLICH
|
|
int GTAO_SKIN_MIX = 0;
|
|
int GTAO_HAIR_COLOR = rnd.Next(0, 18);
|
|
int GTAO_EYEBROWS = 1;
|
|
int GTAO_EYEBROWS_COLOR = 1;
|
|
int HAIR = rnd.Next(1, 36);
|
|
if (HAIR == 23)
|
|
{
|
|
HAIR = 2;
|
|
}
|
|
int LEGS = malelegs[rnd.Next(0, malelegs.Count)];
|
|
int FEET = 1;
|
|
|
|
command.Parameters.AddWithValue("@GTAO_SHAPE_FIRST_ID", GTAO_SHAPE_FIRST_ID);
|
|
command.Parameters.AddWithValue("@GTAO_SHAPE_SECOND_ID", GTAO_SHAPE_SECOND_ID);
|
|
command.Parameters.AddWithValue("@GTAO_SKIN_FIRST_ID", GTAO_SHAPE_FIRST_ID);
|
|
command.Parameters.AddWithValue("@GTAO_SKIN_SECOND_ID", GTAO_SHAPE_SECOND_ID);
|
|
//
|
|
command.Parameters.AddWithValue("@GTAO_SHAPE_MIX", GTAO_SHAPE_MIX);
|
|
command.Parameters.AddWithValue("@GTAO_SKIN_MIX", GTAO_SKIN_MIX);
|
|
//
|
|
command.Parameters.AddWithValue("@GTAO_HAIR_COLOR", GTAO_HAIR_COLOR);
|
|
command.Parameters.AddWithValue("@GTAO_HAIR_HIGHLIGHT_COLOR", GTAO_HAIR_COLOR);
|
|
//
|
|
command.Parameters.AddWithValue("@GTAO_EYEBROWS", GTAO_EYEBROWS);
|
|
command.Parameters.AddWithValue("@GTAO_EYEBROWS_COLOR", GTAO_EYEBROWS_COLOR);
|
|
command.Parameters.AddWithValue("@GTAO_EYEBROWS_COLOR2", GTAO_EYEBROWS_COLOR);
|
|
//
|
|
command.Parameters.AddWithValue("@GTAO_LIPSTICK", 0);
|
|
command.Parameters.AddWithValue("@GTAO_MAKEUP", 0);
|
|
//
|
|
// FACE/LEGS
|
|
//
|
|
command.Parameters.AddWithValue("@HAIR", HAIR);
|
|
command.Parameters.AddWithValue("@HAIR_COLOR", GTAO_HAIR_COLOR);
|
|
command.Parameters.AddWithValue("@LEGS", LEGS);
|
|
command.Parameters.AddWithValue("@BAGS", 0);
|
|
command.Parameters.AddWithValue("@FEET", FEET);
|
|
command.Parameters.AddWithValue("@ACCESSORIES", 0);
|
|
command.Parameters.AddWithValue("@BODYARMOR", 0);
|
|
command.Parameters.AddWithValue("@TOP", CharacterOutfits.Outfits_Male.DEFAULT.X);
|
|
command.Parameters.AddWithValue("@TOP_COLOR", 1);
|
|
command.Parameters.AddWithValue("@UNDERSHIRT", CharacterOutfits.Outfits_Male.DEFAULT.Y);
|
|
command.Parameters.AddWithValue("@TORSO", CharacterOutfits.Outfits_Male.DEFAULT.Z);
|
|
//
|
|
//
|
|
}
|
|
else
|
|
{
|
|
Random rnd = new Random();
|
|
int GTAO_SHAPE_FIRST_ID = rnd.Next(31, 41);
|
|
int GTAO_SHAPE_SECOND_ID = GTAO_SHAPE_FIRST_ID;
|
|
int GTAO_SHAPE_MIX = 0;
|
|
int GTAO_SKIN_MIX = 0;
|
|
int GTAO_HAIR_COLOR = rnd.Next(0, 18);
|
|
int GTAO_EYEBROWS = 1;
|
|
int GTAO_EYEBROWS_COLOR = 1;
|
|
int GTAO_LIPSTICK = 1;
|
|
int GTAO_MAKEUP = 5;
|
|
int HAIR = rnd.Next(1, 38);
|
|
if(HAIR == 24)
|
|
{
|
|
HAIR = 4;
|
|
}
|
|
int LEGS = femalelegs[rnd.Next(0, femalelegs.Count)];
|
|
int FEET = 0;
|
|
|
|
command.Parameters.AddWithValue("@GTAO_SHAPE_FIRST_ID", GTAO_SHAPE_FIRST_ID);
|
|
command.Parameters.AddWithValue("@GTAO_SHAPE_SECOND_ID", GTAO_SHAPE_SECOND_ID);
|
|
command.Parameters.AddWithValue("@GTAO_SKIN_FIRST_ID", GTAO_SHAPE_FIRST_ID);
|
|
command.Parameters.AddWithValue("@GTAO_SKIN_SECOND_ID", GTAO_SHAPE_SECOND_ID);
|
|
//
|
|
command.Parameters.AddWithValue("@GTAO_SHAPE_MIX", GTAO_SHAPE_MIX);
|
|
command.Parameters.AddWithValue("@GTAO_SKIN_MIX", GTAO_SKIN_MIX);
|
|
//
|
|
command.Parameters.AddWithValue("@GTAO_HAIR_COLOR", GTAO_HAIR_COLOR);
|
|
command.Parameters.AddWithValue("@GTAO_HAIR_HIGHLIGHT_COLOR", GTAO_HAIR_COLOR);
|
|
//
|
|
command.Parameters.AddWithValue("@GTAO_EYEBROWS", GTAO_EYEBROWS);
|
|
command.Parameters.AddWithValue("@GTAO_EYEBROWS_COLOR", GTAO_EYEBROWS_COLOR);
|
|
command.Parameters.AddWithValue("@GTAO_EYEBROWS_COLOR2", GTAO_EYEBROWS_COLOR);
|
|
//
|
|
|
|
command.Parameters.AddWithValue("@GTAO_LIPSTICK", GTAO_LIPSTICK);
|
|
command.Parameters.AddWithValue("@GTAO_MAKEUP", GTAO_MAKEUP);
|
|
//
|
|
// CLOTHES
|
|
//
|
|
command.Parameters.AddWithValue("@HAIR", HAIR);
|
|
command.Parameters.AddWithValue("@HAIR_COLOR", GTAO_HAIR_COLOR);
|
|
command.Parameters.AddWithValue("@LEGS", LEGS);
|
|
command.Parameters.AddWithValue("@BAGS", 0);
|
|
command.Parameters.AddWithValue("@FEET", FEET);
|
|
command.Parameters.AddWithValue("@ACCESSORIES", 0);
|
|
command.Parameters.AddWithValue("@BODYARMOR", 0);
|
|
command.Parameters.AddWithValue("@TOP", CharacterOutfits.Outfits_Female.DEFAULT.X);
|
|
command.Parameters.AddWithValue("@TOP_COLOR", 1);
|
|
command.Parameters.AddWithValue("@UNDERSHIRT", CharacterOutfits.Outfits_Female.DEFAULT.Y);
|
|
command.Parameters.AddWithValue("@TORSO", CharacterOutfits.Outfits_Female.DEFAULT.Z);
|
|
}
|
|
connection.Open();
|
|
command.ExecuteNonQuery();
|
|
connection.Close();
|
|
}
|
|
|
|
public static void setPlayerDatabaseClothes(Client player, API API)
|
|
{
|
|
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "SELECT * FROM `character` WHERE `nickname` ='" + player.name + "'";
|
|
connection.Open();
|
|
reader = command.ExecuteReader();
|
|
|
|
int GTAO_SHAPE_FIRST_ID = 0;
|
|
int GTAO_SHAPE_SECOND_ID = 0;
|
|
int GTAO_SHAPE_MIX = 0; // HÖHER ALS 50% MÄNNNLICH
|
|
int GTAO_SKIN_MIX = 0; // HÖHER ALS 50% MÄNNNLICH
|
|
int GTAO_HAIR_COLOR = 0;
|
|
int GTAO_EYEBROWS = 0;
|
|
int GTAO_EYEBROWS_COLOR = 0;
|
|
int GTAO_LIPSTICK = 0;
|
|
int GTAO_MAKEUP = 0;
|
|
int HAIR = 0;
|
|
int TOP = 0;
|
|
int TOP_COLOR = 0;
|
|
int UNDERSHIRT = 0;
|
|
int TORSO = 0;
|
|
int LEGS = 0;
|
|
int LEGS_COLOR = 0;
|
|
int BAGS = 0;
|
|
int FEET = 0;
|
|
int FEET_COLOR = 0;
|
|
int GESCHLECHT = 0;
|
|
int MASK = 0;
|
|
int MASK_COLOR = 0;
|
|
|
|
while (reader.Read())
|
|
{
|
|
GTAO_SHAPE_FIRST_ID = reader.GetInt32("GTAO_SHAPE_FIRST_ID");
|
|
GTAO_SHAPE_SECOND_ID = reader.GetInt32("GTAO_SHAPE_SECOND_ID");
|
|
GTAO_SHAPE_MIX = reader.GetInt32("GTAO_SHAPE_MIX");
|
|
GTAO_SKIN_MIX = reader.GetInt32("GTAO_SKIN_MIX");
|
|
GTAO_HAIR_COLOR = reader.GetInt32("GTAO_HAIR_COLOR");
|
|
GTAO_EYEBROWS = reader.GetInt32("GTAO_EYEBROWS");
|
|
GTAO_EYEBROWS_COLOR = reader.GetInt32("GTAO_EYEBROWS_COLOR");
|
|
GTAO_LIPSTICK = reader.GetInt32("GTAO_LIPSTICK");
|
|
GTAO_MAKEUP = reader.GetInt32("GTAO_MAKEUP");
|
|
HAIR = reader.GetInt32("HAIR");
|
|
TOP = reader.GetInt32("TOP");
|
|
TOP_COLOR = reader.GetInt32("TOP_COLOR");
|
|
UNDERSHIRT = reader.GetInt32("UNDERSHIRT");
|
|
TORSO = reader.GetInt32("TORSO");
|
|
LEGS = reader.GetInt32("LEGS");
|
|
LEGS_COLOR = reader.GetInt32("LEGS_COLOR");
|
|
BAGS = reader.GetInt32("BAGS");
|
|
FEET = reader.GetInt32("FEET");
|
|
FEET_COLOR = reader.GetInt32("FEET_COLOR");
|
|
GESCHLECHT = reader.GetInt32("geschlecht");
|
|
MASK = reader.GetInt32("MASK");
|
|
MASK_COLOR = reader.GetInt32("MASK_COLOR");
|
|
|
|
API.exported.gtaocharacter.initializePedFace(player.handle);
|
|
API.setEntitySyncedData(player.handle, "GTAO_SHAPE_FIRST_ID", GTAO_SHAPE_FIRST_ID);
|
|
API.setEntitySyncedData(player.handle, "GTAO_SHAPE_SECOND_ID", GTAO_SHAPE_SECOND_ID);
|
|
API.setEntitySyncedData(player.handle, "GTAO_SKIN_FIRST_ID", GTAO_SHAPE_FIRST_ID);
|
|
API.setEntitySyncedData(player.handle, "GTAO_SKIN_SECOND_ID", GTAO_SHAPE_SECOND_ID);
|
|
API.setEntitySyncedData(player.handle, "GTAO_SHAPE_MIX", GTAO_SHAPE_MIX);
|
|
API.setEntitySyncedData(player.handle, "GTAO_SKIN_MIX", GTAO_SKIN_MIX);
|
|
API.setEntitySyncedData(player.handle, "GTAO_HAIR_COLOR", GTAO_HAIR_COLOR);
|
|
API.setEntitySyncedData(player.handle, "GTAO_EYEBROWS", GTAO_EYEBROWS);
|
|
API.setEntitySyncedData(player.handle, "GTAO_EYEBROWS_COLOR", GTAO_EYEBROWS_COLOR);
|
|
|
|
if(GESCHLECHT == 0)
|
|
{
|
|
API.setEntitySyncedData(player.handle, "GTAO_LIPSTICK", GTAO_LIPSTICK);
|
|
}
|
|
else
|
|
{
|
|
API.resetEntitySyncedData(player.handle, "GTAO_LIPSTICK");
|
|
}
|
|
if(GESCHLECHT == 0)
|
|
{
|
|
API.setEntitySyncedData(player.handle, "GTAO_MAKEUP", GTAO_MAKEUP);
|
|
}
|
|
else
|
|
{
|
|
API.resetEntitySyncedData(player.handle, "GTAO_MAKEUP");
|
|
}
|
|
|
|
//CLOTHES
|
|
API.setPlayerClothes(player, 2, HAIR, 0);
|
|
API.setPlayerClothes(player, 4, LEGS, LEGS_COLOR);
|
|
API.setPlayerClothes(player, 6, FEET, FEET_COLOR);
|
|
API.setPlayerClothes(player, 10, 1, 1);
|
|
|
|
|
|
API.setPlayerClothes(player, 11, TOP, TOP_COLOR);
|
|
API.setPlayerClothes(player, 8, UNDERSHIRT, 0);
|
|
API.setPlayerClothes(player, 3, TORSO, 0);
|
|
API.setPlayerClothes(player, 1, MASK, MASK_COLOR);
|
|
// SHIRT UNDERSHIRT TORSOFIX
|
|
|
|
API.consoleOutput("Character Loaded for: " + player.name);
|
|
API.exported.gtaocharacter.updatePlayerFace(player.handle);
|
|
}
|
|
|
|
connection.Close();
|
|
}
|
|
|
|
public static void saveClothes(Client player,String DATABASEFLAG, int VALUE,API api)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "UPDATE `character` SET `" + DATABASEFLAG +"` = " + VALUE + " WHERE `nickname` = '" + player.name + "'";
|
|
connection.Open();
|
|
command.ExecuteNonQuery();
|
|
connection.Close();
|
|
setPlayerDatabaseClothes(player, api);
|
|
api.consoleOutput("Saved Clothe: " + DATABASEFLAG + " to value " + VALUE + " For PLAYER " + player.name);
|
|
}
|
|
|
|
|
|
}
|
|
}
|