- 10 Сен 2020
- 3,462
- 2,818
- 219
Пробуй так.
C#:
public static void Savep(Player player, string Number)
{
if (!Vehicles.ContainsKey(Number)) return;
VehicleData data = Vehicles[Number];
Vector3 pos;
foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
{
if(veh.NumberPlate == Number)
pos = NAPI.Entity.GetEntityPosition(veh);
}
string items = JsonConvert.SerializeObject(data.Items);
if (string.IsNullOrEmpty(items) || items == null) items = "[]";
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = "UPDATE `vehicles` SET position=@pos WHERE number=@numb";
cmd.Parameters.AddWithValue("@pos", JsonConvert.SerializeObject(pos));
cmd.Parameters.AddWithValue("@numb", Number);
MySQL.Query(cmd);
}