Example #1
0
 public static void LoadVehicles()
 {
     foreach (var vehicle in ContextFactory.Instance.Vehicle.Where(x => x.Group != null).ToList())
     {
         VehicleController VehicleController = new VehicleController(vehicle, API.shared.createVehicle((VehicleHash)vehicle.Model, new Vector3(vehicle.PosX, vehicle.PosY, vehicle.PosZ), new Vector3(0.0f, 0.0f, vehicle.Rot), vehicle.Color1, vehicle.Color2));
         if (vehicle.Group != null) // -1 is reserved for non-group job vehicles.
         {
             VehicleController.Group = EntityManager.GetGroup(vehicle.Group.Id);
         }
     }
     API.shared.consoleOutput("[GM] Loaded vehicles: " + ContextFactory.Instance.Vehicle.Count());
 }
Example #2
0
        public void createjob(Client player, JobType type, int Level, string IDOrName = null)
        {
            AccountController account = player.getData("ACCOUNT");

            if (account == null)
            {
                return;
            }
            if (!AdminController.AdminRankCheck("createproperty", account))
            {
                return;
            }

            Groups.GroupController groupController = null;
            if (IDOrName != null)
            {
                groupController = EntityManager.GetGroup(player, IDOrName);
                if (groupController == null)
                {
                    player.sendChatMessage("~r~ERROR: ~w~You specified an invalid group.");
                    return;
                }
            }
            Data.Job      jobData       = new Data.Job();
            JobController jobController = new JobController(jobData);

            jobController.Group = groupController;
            // _JobData.GroupID = (_GroupController == null ? null : _GroupController._GroupData.GroupID);
            if (groupController == null)
            {
                jobData.GroupId = null;
            }
            else
            {
                jobData.GroupId = groupController.Group.Id;
            }
            jobData.Type = type;

            jobData.PosX = player.position.X;
            jobData.PosY = player.position.Y;
            jobData.PosZ = player.position.Z;

            jobData.Level = Level;
            ContextFactory.Instance.Job.Add(jobData);
            ContextFactory.Instance.SaveChanges();

            jobController.CreateWorldEntity();
            player.sendChatMessage("~g~Server: ~w~ Added job: " + jobController.Type());
        }
Example #3
0
        public void createvehicle(Client player, string OwnerType, string Name, VehicleHash hash, int color1, int color2)
        {
            AccountController account = player.getData("ACCOUNT");

            if (account == null)
            {
                return;
            }
            if (!AdminController.AdminRankCheck("createvehicle", account))
            {
                return;
            }

            Data.Vehicle VehicleData = new Data.Vehicle();
            if (OwnerType == "player")
            {
                AccountController TargetAccountController = AccountController.GetAccountControllerFromName(Name);
                if (TargetAccountController == null)
                {
                    return;
                }
                VehicleData.Character = TargetAccountController.CharacterController.Character;
            }
            else if (OwnerType == "group")
            {
                Groups.GroupController GroupController = EntityManager.GetGroup(player, Name);
                VehicleData.Group = GroupController.Group;
            }
            else
            {
                API.sendChatMessageToPlayer(player, "~r~ERROR: ~w~You specified an invalid owner type (player/group");
                return;
            }

            Vehicles.VehicleController VehicleController = new Vehicles.VehicleController(VehicleData, API.createVehicle(hash, player.position, player.rotation, color1, color2, 0));

            VehicleData.Model  = hash.GetHashCode();
            VehicleData.PosX   = player.position.X;
            VehicleData.PosY   = player.position.Y;
            VehicleData.PosZ   = player.position.Z;
            VehicleData.Rot    = player.rotation.Z;
            VehicleData.Color1 = color1;
            VehicleData.Color2 = color2;

            ContextFactory.Instance.Vehicle.Add(VehicleData);
            ContextFactory.Instance.SaveChanges();
        }
Example #4
0
        public static void CreateProperty(Client player, string ownerType, PropertyType type, string Name)
        {
            Data.Property propertyData = new Data.Property();
            string        ownerName;

            if (ownerType == "player")
            {
                AccountController TargetAccountController = AccountController.GetAccountControllerFromName(Name);
                if (TargetAccountController == null)
                {
                    return;
                }
                propertyData.Character = TargetAccountController.CharacterController.Character;
                ownerName = TargetAccountController.CharacterController.FormatName;
            }
            else if (ownerType == "group")
            {
                Groups.GroupController GroupController = EntityManager.GetGroup(player, Name);
                if (GroupController == null)
                {
                    return;
                }

                propertyData.Group = GroupController.Group;
                ownerName          = GroupController.Group.Name;
            }
            else
            {
                API.shared.sendChatMessageToPlayer(player, "~r~ERROR: ~w~You specified an invalid owner type (player/group");
                return;
            }

            PropertyController PropertyController = new PropertyController(propertyData);

            propertyData.Type            = type;
            propertyData.ExtPosX         = player.position.X;
            propertyData.ExtPosY         = player.position.Y;
            propertyData.ExtPosZ         = player.position.Z;
            PropertyController.ownername = ownerName;

            ContextFactory.Instance.Property.Add(propertyData);
            ContextFactory.Instance.SaveChanges();
            PropertyController.CreateWorldEntity();
            API.shared.sendChatMessageToPlayer(player, "~g~Server: ~w~ Added a " + PropertyController.Type() + " owned by " + ownerName);
        }
Example #5
0
        public void editjob(Client player, int id, JobType type, int Level, string IDOrName = null)
        {
            AccountController account = player.getData("ACCOUNT");

            if (account == null)
            {
                return;
            }
            if (!AdminController.AdminRankCheck("editjob", account))
            {
                return;
            }

            JobController job = EntityManager.GetJob(id);

            if (job == null)
            {
                player.sendChatMessage("~r~ERROR: ~w~You specified an invalid job.");
            }
            else
            {
                Groups.GroupController _GroupController = EntityManager.GetGroup(player, IDOrName);
                if (_GroupController == null)
                {
                    player.sendChatMessage("~r~ERROR: ~w~You specified an invalid group.");
                    return;
                }

                job.Group           = _GroupController;
                job.JobData.GroupId = _GroupController.Group.Id;
                job.JobData.Type    = type;
                job.JobData.Level   = Level;
                player.sendChatMessage("You successfully edited job ID " + id);
                ContextFactory.Instance.SaveChanges();
            }
        }