public void VehicleEditChangeSpawn(Player player, params object[] arguments) { GameVehicle veh = NAPI.Data.GetEntityData(player, "EDIT_VEH"); if (veh == null) { NAPI.Chat.SendChatMessageToPlayer(player, "~r~Vehicle editor error. Null vehicle."); return; } veh.SpawnPos = NAPI.Entity.GetEntityPosition(veh.Entity); veh.SpawnRot = NAPI.Entity.GetEntityRotation(veh.Entity); veh.SpawnDimension = (int)NAPI.Entity.GetEntityDimension(veh.Entity); veh.Save(); NAPI.Chat.SendChatMessageToPlayer(player, "Vehicle position spawn saved to current location."); }
public void VehicleEditSave(Player player, params object[] arguments) { GameVehicle veh = NAPI.Data.GetEntityData(player, "EDIT_VEH"); if (veh == null) { NAPI.Chat.SendChatMessageToPlayer(player, "~r~Vehicle editor error. Null vehicle."); return; } var vehId = Convert.ToInt32(arguments[0]); var model = Convert.ToString(arguments[1]); var owner = Convert.ToString(arguments[2]); var licensePlate = Convert.ToString(arguments[3]); var color1 = (string)arguments[4]; var color2 = (string)arguments[5]; var respawnDelay = Convert.ToInt32(arguments[6]); var jobId = Convert.ToInt32(arguments[7]); var groupId = Convert.ToInt32(arguments[8]); if (veh.Id != vehId) { NAPI.Chat.SendChatMessageToPlayer(player, "~r~Vehicle editor error. Vehicle edit IDs are not equal."); return; } var modelHash = NAPI.Util.VehicleNameToModel(model); if (modelHash == 0) { NAPI.ClientEvent.TriggerClientEvent(player, "send_veh_edit_error", "Invalid vehicle model entered!"); return; } if (!Character.IsCharacterRegistered(owner) && owner != "NONE") { NAPI.ClientEvent.TriggerClientEvent(player, "send_veh_edit_error", "Invalid owner entered. (Character name does not exist.)"); return; } if (JobManager.GetJobById(jobId) == null && jobId != 0) { NAPI.ClientEvent.TriggerClientEvent(player, "send_veh_edit_error", "Invalid job ID entered!"); return; } if (GroupManager.GetGroupById(groupId) == null && groupId != 0) { NAPI.ClientEvent.TriggerClientEvent(player, "send_veh_edit_error", "Invalid group ID entered!"); return; } if (owner == "NONE") { veh.OwnerId = 0; } else { veh.OwnerId = PlayerManager.Players.Single(x => x.CharacterName == owner).Id; } veh.VehModel = modelHash; veh.LicensePlate = licensePlate; veh.VehMods[ModdingManager.PrimaryColorId.ToString()] = color1; veh.VehMods[ModdingManager.SecondryColorId.ToString()] = color2; veh.RespawnDelay = TimeSpan.FromMinutes(respawnDelay); veh.JobId = jobId; veh.Job = JobManager.GetJobById(veh.JobId); veh.Group = GroupManager.GetGroupById(veh.GroupId); veh.GroupId = groupId; VehicleManager.respawn_vehicle(veh, NAPI.Entity.GetEntityPosition(veh.Entity)); NAPI.Player.SetPlayerIntoVehicle(player, veh.Entity, -1); veh.Save(); NAPI.Chat.SendChatMessageToPlayer(player, "Vehicle editor changes saved!"); NAPI.ClientEvent.TriggerClientEvent(player, "finish_veh_edit"); }