Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int SavePlayerCharacter(PlayerModule playerModule)
- {
- // just init return value
- int id = -1
- // use mysql connection
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- // generate MySqlCommand
- MySqlCommand command = connection.CreateCommand();
- // INSERT command Builder
- command.CommandText = "INSERT INTO characters VALUES(@characterName, @accountID, @firstName, @lastName, @birthday, @age, @posX, @posY, @posZ, @rotation, @money, @bank, @armor, @sex, ";
- command.CommandText += "@fraction, @job, @rank, @phone, @radio, @jailed, @vehicleKeys, @documentation, @license, @insurance, @weaponLicense, @houseRent, @houseEntered, @businesEntered, ";
- command.CommandText += "@jobDeliver, @jobColldown, @played, @status, @socialName, @adminRank, @adminname, @employeeCooldown, @duty, @killed, @jobPoints, @rolePoints)";
- command.Parameters.AddWithValue("@characterName", playerModule.firstName + " " + playerModule.lastName);
- command.Parameters.AddWithValue("@accountID", playerModule.id);
- command.Parameters.AddWithValue("@firstName", playerModule.firstName);
- command.Parameters.AddWithValue("@lastName", playerModule.lastName);
- command.Parameters.AddWithValue("@birthdate", playerModule.birthdate);
- command.Parameters.AddWithValue("@realName", playerModule.realName);
- command.Parameters.AddWithValue("@adminName", playerModule.adminName);
- command.Parameters.AddWithValue("@adminRank", playerModule.adminRank);
- command.Parameters.AddWithValue("@posX", playerModule.position.X);
- command.Parameters.AddWithValue("@posY", playerModule.position.Y);
- command.Parameters.AddWithValue("@posZ", playerModule.position.Z);
- command.Parameters.AddWithValue("@rotation", playerModule.rotation.Z);
- command.Parameters.AddWithValue("@money", playerModule.money);
- command.Parameters.AddWithValue("@bank", playerModule.bank);
- command.Parameters.AddWithValue("@health", playerModule.health);
- command.Parameters.AddWithValue("@armor", playerModule.armor);
- command.Parameters.AddWithValue("@age", playerModule.age);
- command.Parameters.AddWithValue("@sex", playerModule.sex);
- command.Parameters.AddWithValue("@fraction", playerModule.fraction);
- command.Parameters.AddWithValue("@job", playerModule.job);
- command.Parameters.AddWithValue("@duty", playerModule.duty);
- command.Parameters.AddWithValue("@phone", playerModule.phone);
- command.Parameters.AddWithValue("@rank", playerModule.rank);
- command.Parameters.AddWithValue("@killed", playerModule.killed);
- command.Parameters.AddWithValue("@jailed", playerModule.jailed);
- command.Parameters.AddWithValue("@vehiecleKeys", playerModule.vehiecleKeys);
- command.Parameters.AddWithValue("@documentation", playerModule.documentation);
- command.Parameters.AddWithValue("@licenses", playerModule.licenses);
- command.Parameters.AddWithValue("@insurance", playerModule.insurance);
- command.Parameters.AddWithValue("@weaponLicense", playerModule.weaponLicense);
- command.Parameters.AddWithValue("@houseRent", playerModule.houseRent);
- command.Parameters.AddWithValue("@houseEntered", playerModule.houseEntered);
- command.Parameters.AddWithValue("@businessEntered", playerModule.businessEntered);
- command.Parameters.AddWithValue("@jobDeliver", playerModule.jobDeliver);
- command.Parameters.AddWithValue("@jobCooldown", playerModule.jobCooldown);
- command.Parameters.AddWithValue("@played", playerModule.played);
- command.Parameters.AddWithValue("@status", playerModule.status);
- command.Parameters.AddWithValue("@socialName", playerModule.socialName);
- command.Parameters.AddWithValue("@employeeCooldown", playerModule.employeeCooldown);
- command.Parameters.AddWithValue("@jobPoints", playerModule.jobPoints);
- // open the Connection
- connection.Open();
- // prepare the command
- command.Prepare();
- try
- {
- //execute Command
- command.ExecuteNonQuery();
- }
- catch (Exception ex)
- {
- // write exeption on Console
- NAPI.Util.ConsoleOutput("[EXCEPTION SaveCharacter] " + ex.Message);
- NAPI.Util.ConsoleOutput("[EXCEPTION SaveCharacter] " + ex.StackTrace);
- }
- // get lastInsertID
- id = (int)command.LastInsertedId;
- // return the Character ID
- return id;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement