Esempio n. 1
0
        public void cmd_V(Client player, string input)
        {
            string[] param = input.Split(null);

            if (param[0] == "lista")
            {
                Dictionary <int, int> vehicles = VehicleClass.ListPlayerVehicles(player);
                if (vehicles.Count > 0)
                {
                    string json = API.toJson(vehicles);
                    API.triggerClientEvent(player, "vehicle_select", json);
                }
                else
                {
                    API.sendNotificationToPlayer(player, "Nie posiadasz żadnego pojazdu.");
                    return;
                }
            }
            if (param[0] == "zamknij" || param[0] == "z")
            {
                NetHandle vehicle = VehicleClass.GetNearestVehicle(player.position, 5f);

                if (!VehicleClass.IsPlayerHasPermForVehicle(player, vehicle))
                {
                    API.sendNotificationToPlayer(player, "Nie jesteś właścicielem tego pojazdu.");
                    return;
                }

                bool lk = !API.getVehicleLocked(vehicle);
                API.setVehicleLocked(vehicle, lk);
                API.sendNotificationToPlayer(player, (lk ? "Zamknąłeś" : "Otworzyłeś") + " pojazd!");
            }
            if (param[0] == "zaparkuj")
            {
                if (!API.isPlayerInAnyVehicle(player))
                {
                    API.sendNotificationToPlayer(player, "Nie znajdujesz się w żadnym pojeździe.");
                    return;
                }

                NetHandle    vehicle = API.getPlayerVehicle(player);
                VehicleClass vc      = API.getEntityData(vehicle, "data");

                if (!VehicleClass.IsPlayerHasPermForVehicle(player, vehicle))
                {
                    API.sendNotificationToPlayer(player, "Nie jesteś właścicielem tego pojazdu.");
                    return;
                }

                VehicleClass.ParkVehicle(vehicle);
                API.sendNotificationToPlayer(player, "Pomyślnie zaparkowano pojazd.");
            }
        }
Esempio n. 2
0
        public void cmd_Av(Client player, string input)
        {
            if (player.getData("admin") > 0)
            {
                string[] param = input.Split(null);
                if (param[0] == "usun")      // av usun idwozu
                {
                    if (param.Length != 2)
                    {
                        API.sendChatMessageToPlayer(player, "Użycie: /av usun [ID pojazdu]");
                        return;
                    }

                    int       vehicle_id = Convert.ToInt32(param[1]);
                    NetHandle vehicle    = VehicleClass.GetVehicleById(vehicle_id);

                    if (vehicle.IsNull)
                    {
                        API.sendNotificationToPlayer(player, "Nie znaleziono pojazdu o takim ID.");
                        return;
                    }

                    VehicleClass.DeleteVehicle(vehicle);
                    API.sendNotificationToPlayer(player, "Pomyślnie usunięto pojazd.");
                }
                if (param[0] == "stworz")    // av stworz sentinel 0 1
                {
                    if (param.Length != 4)
                    {
                        API.sendChatMessageToPlayer(player, "Użycie: /av stworz [model] [kolor1] [kolor2]");
                        return;
                    }

                    VehicleHash model = API.vehicleNameToModel(param[1]);
                    int         col1 = Int32.Parse(param[2]), col2 = Int32.Parse(param[3]);

                    if (model == 0)
                    {
                        API.sendNotificationToPlayer(player, "~r~Nie znaleziono ~w~pojazdu o takim modelu!");
                        return;
                    }

                    Vector3 new_pos = player.position;
                    new_pos.X += 2;
                    new_pos.Y += 2;

                    NetHandle vehicle = VehicleClass.CreateVehicle(model, new_pos, new Vector3(0, 0, 0), col1, col2, player.dimension);
                    API.sendNotificationToPlayer(player, "Pomyślnie utworzono pojazd marki " + param[1]);
                }
                if (param[0] == "kolor")    // av color IDveh IDC1 IDC2
                {
                    if (param.Length != 4)
                    {
                        API.sendChatMessageToPlayer(player, "Użycie: /av kolor [ID wozu] [kolor1] [kolor2]");
                        return;
                    }

                    int       vehicle_id = Convert.ToInt32(param[1]);
                    int       color1     = Convert.ToInt32(param[2]);
                    int       color2     = Convert.ToInt32(param[3]);
                    NetHandle vehicle    = VehicleClass.GetVehicleById(vehicle_id);

                    if (vehicle.IsNull)
                    {
                        API.sendNotificationToPlayer(player, "Nie znaleziono pojazdu o takim ID.");
                        return;
                    }

                    VehicleClass.UpdateVehicleMainColors(vehicle, color1, color2);
                    API.sendNotificationToPlayer(player, "Pomyślnie zmieniono kolory pojazdu.");
                }
                if (param[0] == "fix")    // av fix ID
                {
                    if (param.Length != 2)
                    {
                        API.sendChatMessageToPlayer(player, "Użycie: /av fix [ID pojazdu]");
                        return;
                    }

                    int       vehicle_id = Int32.Parse(param[1]);
                    NetHandle vehicle    = VehicleClass.GetVehicleById(vehicle_id);

                    if (vehicle.IsNull)
                    {
                        API.sendNotificationToPlayer(player, "Nie znaleziono pojazdu o takim ID.");
                        return;
                    }

                    API.repairVehicle(vehicle);
                    API.sendNotificationToPlayer(player, "Pomyślnie naprawiono pojazd.");
                }
                if (param[0] == "przypisz")  // av przypisz gracz 1 1
                {
                    if (param.Length != 4)
                    {
                        API.sendChatMessageToPlayer(player, "Użycie: /av przypisz [gracz/grupa] [ID Wozu] [ID Wlasciciela]");
                        return;
                    }

                    string towho      = param[1];
                    int    vehicle_id = Int32.Parse(param[2]);
                    int    owner_id   = Int32.Parse(param[3]);

                    if (towho == "gracz")
                    {
                        Client    target  = PlayerClass.GetPlayerById(owner_id);
                        NetHandle vehicle = VehicleClass.GetVehicleById(vehicle_id);

                        if (target.IsNull || vehicle.IsNull || !target.getData("logged"))
                        {
                            API.sendChatMessageToPlayer(player, "Błąd: Wystąpił błąd podczas przypisywania pojazdu.");
                            return;
                        }

                        VehicleClass vc = API.getEntityData(vehicle, "data");
                        PlayerClass  pc = target.getData("data");
                        vc.ownertype = Config.OWNER_PLAYER;
                        vc.owner     = pc.uid;

                        VehicleClass.UpdateVehicleOwner(vc.uid, vc.ownertype, vc.owner);
                        API.sendChatMessageToPlayer(player, String.Format("Pomyślnie przepisano pojazd {0} graczowi {1} [{2}]", API.getVehicleDisplayName(vc.model), pc.displayName, pc.id));
                    }
                    if (towho == "grupa")
                    {
                        /// TODO
                    }
                }
                if (param[0] == "debug")
                {
                    NetHandle vehicle = API.getPlayerVehicle(player);
                    if (!vehicle.IsNull)
                    {
                        API.sendChatMessageToPlayer(player, String.Format("Paliwo: {0}", API.getVehicleFuelLevel(vehicle)));
                        API.sendChatMessageToPlayer(player, String.Format("Olej: {0}", API.getVehicleOilLevel(vehicle)));
                        API.sendChatMessageToPlayer(player, String.Format("HP i EngineHP: {0}, {1}", API.getVehicleHealth(vehicle), API.getVehicleEngineHealth(vehicle)));
                    }
                }

                if (param[0] == "goto")
                {
                    if (param.Length != 2)
                    {
                        API.sendChatMessageToPlayer(player, "Użycie: /av goto [ID]");
                        return;
                    }
                    if (VehicleClass.GetVehicleById(Convert.ToInt32(param[1])).IsNull)
                    {
                        API.sendChatMessageToPlayer(player, "Nie ma pojazdu o takim ID.");
                        return;
                    }
                    NetHandle vehicle = VehicleClass.GetVehicleById(Convert.ToInt32(param[1]));
                    Vector3   new_pos = API.getEntityPosition(vehicle);
                    new_pos.X += 2;
                    new_pos.Y += 2;
                    API.setEntityDimension(player, API.getEntityDimension(vehicle));
                    API.setEntityPosition(player, new_pos);
                }

                if (param[0] == "gethere")
                {
                    if (param.Length != 2)
                    {
                        API.sendChatMessageToPlayer(player, "Użycie: /av gethere [ID]");
                        return;
                    }
                    if (VehicleClass.GetVehicleById(Convert.ToInt32(param[1])).IsNull)
                    {
                        API.sendChatMessageToPlayer(player, "Nie ma pojazdu o takim ID.");
                        return;
                    }
                    NetHandle vehicle = VehicleClass.GetVehicleById(Convert.ToInt32(param[1]));
                    Vector3   new_pos = player.position;
                    new_pos.X += 2;
                    new_pos.Y += 2;
                    API.setEntityDimension(vehicle, player.dimension);
                    API.setEntityPosition(vehicle, new_pos);
                }

                if (param[0] == "zaparkuj")
                {
                    if (param.Length != 2)
                    {
                        API.sendChatMessageToPlayer(player, "Użycie: /av zaparkuj [ID]");
                        return;
                    }
                    if (VehicleClass.GetVehicleById(Convert.ToInt32(param[1])).IsNull)
                    {
                        API.sendChatMessageToPlayer(player, "Nie ma pojazdu o takim ID.");
                        return;
                    }
                    NetHandle vehicle = VehicleClass.GetVehicleById(Convert.ToInt32(param[1]));
                    VehicleClass.ParkVehicle(vehicle);
                    API.sendNotificationToPlayer(player, "Przeparkowałeś pojazd o ID: " + param[1]);
                }
            }
        }