Esempio n. 1
0
 /// <summary>
 /// API Change Health
 /// </summary>
 /// <param name="player"></param>
 /// <param name="oldValue"></param>
 public static void OnPlayerHealthChangeHandler(Client player, int oldValue)
 {
     try
     {
         PlayerClass p = player.getData("data");
         if (p.uid > 0)
         {
             p.health = player.health;
         }
     } catch
     {
         return;
     }
 }
Esempio n. 2
0
        public static Boolean OnPlayerLogin(Client player, double x, double y, double z, bool crash)
        {
            PlayerClass p = player.getData("data");

            player.setSkin(p.skin);
            player.name    = p.name;
            player.nametag = p.displayName;
            player.health  = p.health;
            Utils.SetMoney(player, p.cash);
            if (Config.DEBUG_MODE == true && player.getData("admin") != 0)
            {
                API.shared.sendNotificationToPlayer(player, "~r~Serwer odpalony w trybie debugowania", false);
            }

            // GTAO: Character
            GTAOnlineCharacter.initializePedFace(player);
            GTAOnlineCharacter.initializeMyClothes(player);
            GTAOnlineCharacter.updatePlayerFace(player);

            // Items
            ItemManager.LoadPlayerItems(player);
            //ItemManager.Debug_ListPlayerItems(player);

            if (crash)
            {
                API.shared.setEntityPosition(player, new Vector3(x, y, z));
                API.shared.setEntityDimension(player, p.vw);
                Database.UpdateCrash(player, false);
            }

            // Nametag
            player.nametag = p.displayName.Replace("_", " ") + " (" + p.id + ")";

            // Message (admin previlages)
            int admin = player.getData("admin");

            if (admin > 0)
            {
                API.shared.sendNotificationToPlayer(player, "~h~Wczytano uprawnienia ~r~administratora", true);
            }
            else if (admin < 0)
            {
                API.shared.sendNotificationToPlayer(player, "~h~Wczytano uprawnienia ~b~supportera", true);
            }

            player.setData("logged", true);
            return(true);
        }
Esempio n. 3
0
        public static int GetPlayerID(Client player)
        {
            PlayerClass pc = player.getData("data");

            return(pc.id);
        }
Esempio n. 4
0
        public static void API_OnClientEvent(Client player, string eventName, params object[] arguments) //arguments param can contain multiple params
        {
            if (eventName == "menu_handler_select_item")                                                 // ON MENU CLICK
            {
                string callbackId = arguments[0].ToString();
                if (callbackId == "character_selected") // SELECT CHARACTER ON LOGIN
                {
                    string char_name = arguments[1].ToString();
                    string char_id   = arguments[2].ToString();

                    Database.GetCharacterData(player, Int32.Parse(char_id));
                    API.shared.consoleOutput("Gracz " + char_name.ToString() + " (UID: " + char_id.ToString() + ") zalogował się.");
                }
            }

            if (eventName == "vehicle_selected_item")
            {
                int       vehicle_uid = Int32.Parse(arguments[0].ToString());
                NetHandle vehicle     = VehicleClass.GetVehicleByUid(vehicle_uid);

                if (vehicle.IsNull)
                {
                    VehicleClass.LoadVehicle(vehicle_uid);
                    API.shared.sendChatMessageToPlayer(player, "Pomyślnie zespawnowano pojazd.");
                }
                else
                {
                    VehicleClass.UnloadVehicle(vehicle);
                    API.shared.sendChatMessageToPlayer(player, "Pomyślnie odspawnowano pojazd.");
                }

                API.shared.triggerClientEvent(player, "hide_menu");
            }

            if (eventName == "item_selected_item")
            {
                int item_uid = Int32.Parse(arguments[0].ToString());
                int idx      = Int32.Parse(arguments[1].ToString());

                if (item_uid > 0)
                {
                    if (idx == 0)    // use
                    {
                        Items.Item.Use(player, item_uid);
                    }
                    if (idx == 1)    // drop
                    {
                        Items.Item.Drop(player, item_uid);
                    }
                }
                API.shared.triggerClientEvent(player, "hide_menu");
            }

            if (eventName == "item_select_item")
            {
                API.shared.triggerClientEvent(player, "hide_menu");
                API.shared.triggerClientEvent(player, "item_selected");
            }

            if (eventName == "vehicle_select_item")
            {
                API.shared.triggerClientEvent(player, "hide_menu");
                API.shared.triggerClientEvent(player, "vehicle_selected");
            }

            if (eventName == "start_stop_engine") // START STOP ENGINE
            {
                VehicleClass.StartStopEngine(player);
            }

            if (eventName == "client_p")
            {
                Commands.cmd_P(player, "lista");
            }

            if (eventName == "client_e")
            {
                if (API.shared.isPlayerInAnyVehicle(player))
                {
                }
                else
                {
                    // Check is any free object in range.
                    Item item = Item.GetItemInRangeOfPlayer(player);
                    if (item != null)
                    {
                        PlayerClass pc = API.shared.getEntityData(player, "data");
                        item.place = Config.PLACE_ITEM_PLAYER;
                        item.owner = pc.uid;
                        item.posz  = 0f;
                        item.posx  = 0f;
                        item.posy  = 0f;

                        Item.FloorItems.Remove(item);
                        Item.PlayerItems[player.handle].Add(item);

                        Commands.cmd_me(player, String.Format("podnosi przedmiot {0}.", item.name));
                        Item.Save(item.uid, (Config.ITEM_SAVE_OWNER | Config.ITEM_SAVE_POS));

                        API.shared.playPlayerAnimation(player, (int)(Config.AnimationFlags.AllowPlayerControl), "anim@mp_snowball", "pickup_snowball");
                        NetHandle label = API.shared.getEntityData(item.obj, "label");
                        API.shared.deleteEntity(label);
                        API.shared.deleteEntity(item.obj);
                        return;
                    }
                }
            }
        }