Ejemplo n.º 1
0
        public void unlockVehicle(Client player, NetHandle vehicle)
        {
            if (API.hasEntityData(vehicle, "JSON_DATA") == false)
            {
                return;
            }

            API.sendChatMessageToPlayer(player, player.handle.ToString());

            bool    locked          = API.getVehicleLocked(vehicle);
            dynamic vehData         = API.fromJson(API.getEntityData(vehicle, "JSON_DATA"));
            bool    playerCanUnlock = API.getEntityData(player.handle, "CHAR_ID") == (int)(vehData.OwnerId);
            string  vehName         = API.getVehicleDisplayName((VehicleHash)API.getEntityModel(vehicle));

            if (vehicle.ToString() != "0" && playerCanUnlock)
            {
                // unlock vehicle
                API.setVehicleLocked(vehicle, !locked);
                //API.playPlayerAnimation(player, 0, "cellphone@", "f_cellphone_text_in");

                // alert player
                if (!locked)
                {
                    API.sendNotificationToPlayer(player, "~r~" + vehName + " locked");
                }
                else
                {
                    API.sendNotificationToPlayer(player, "~g~" + vehName + " unlocked");
                }

                // TODO: make it so playing a mp3 multiple times does not crash the game
                // play unlock sound for nearby players

                /*
                 * List<Client> nearbyPlayers = API.getPlayersInRadiusOfPosition(15f, API.getEntityPosition(vehicle));
                 * foreach (Client p in nearbyPlayers) {
                 *  API.triggerClientEvent(p, "play_vehicle_unlock_sound");
                 * }
                 */
            }
            else if (vehicle.ToString() != "0" && !playerCanUnlock)
            {
                API.sendNotificationToPlayer(player, "~r~You do not have the keys for this " + vehName);
            }
        }
Ejemplo n.º 2
0
 private void ProcessCodeMajorThree(AsyncStateOne state, NetHandle handle, string data)
 {
     if (handle.CodeIdentifier == 1)
     {
         // 下面可以再if..else
         //net_simplify_server.SendMessage(state, handle, "测试数据大类3,命令1,接收到的数据是:" + data);
         //this.richTextBox1.Text += "发送的数据" + data.ToString();
         try
         {
             string sql = string.Empty;
             sql = "select UserID from UserLogin where UserName=\"" + data + "\"";
             //string sql = textBox1.Text;
             richTextBox1.Text += sql + "\r\n";
             string result = string.Empty;
             //执行查询
             MySqlDataReader reader = mc.ExeQuery(sql);
             while (reader.Read())
             {
                 result = reader.GetValue(0).ToString();
             }
             if (result != string.Empty)
             {
                 result = "0";
                 net_simplify_server.SendMessage(state, handle, result);
                 richTextBox1.Text += state.ToString() + "\t" + handle.ToString() + "\t" + result + "\r\n";
             }
             else
             {
                 result = "1";
                 net_simplify_server.SendMessage(state, handle, result);
                 richTextBox1.Text += state.ToString() + "\t" + handle.ToString() + "\t" + result + "\r\n";
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK);
         }
     }
     else
     {
         net_simplify_server.SendMessage(state, handle, data);
         this.richTextBox1.Text += "发送的数据" + data.ToString();
     }
 }
Ejemplo n.º 3
0
 private void Net_socket_client_AcceptByte(AppSession session, NetHandle customer, byte[] object2)
 {
     // 接收到服务器发来的字节数据
     if (IsHandleCreated)
     {
         Invoke(new Action(() =>
         {
             MessageBox.Show(customer.ToString());
         }));
     }
 }
Ejemplo n.º 4
0
 private void Net_socket_client_AcceptByte(AsyncStateOne object1, NetHandle customer, byte[] object2)
 {
     //接收到服务器发来的字节数据
     if (IsWindowShow)
     {
         Dispatcher.Invoke(new Action(() =>
         {
             MessageBox.Show(customer.ToString());
         }));
     }
 }